1+ /*
2+ ¬°¤*,¸¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸
3+ ¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯
4+
5+ __/¯\____ ___/\__ _/\__ _/\_ _/\__ _/\___ ___/\__ __/\_ _/\__
6+ \_ ____/_> ____ \_/ _ \_ \ < /_ \_/ _>> ____ \_ > \_/ _ \_
7+ _> ___/ ¯>__> <<__// __ _/ |> ></ _/> </ ¯ \\__> <<__// /\ // __ _/
8+ _> \7 <__/:. \__/:. \> \_/ L/ _____/. 7> .\_/:. \__/ <_/ </:. \> \_
9+ |:::::::::::::::::::::::/:::::::::::::>::::::::/::::::::::::::::::::::::/:::::|
10+ |¯¯\::::/\:/¯\::::/¯¯¯¯<::::/\::/¯¯\:/¯¯¯¯¯¯\::\::/¯¯\::::/¯¯\::::/¯¯¯¯<::::/¯|
11+ |__ |¯¯| T _ |¯¯¯| ___ |¯¯| |¯| _ T ______ |¯¯¯¯| _ |¯¯¯| _ |¯¯¯| ___ |¯¯| _|
12+ \|__|/\|/ \|___|/ \|__|/\|_|/ \|/ \| |/ \|___|/ \|___|/dNo\|__|/
13+
14+ ¬°¤*,¸¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸
15+ ¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯
16+
17+ This file is part of Etripator,
18+ copyright (c) 2009--2024 Vincent Cruz.
19+
20+ Etripator is free software: you can redistribute it and/or modify
21+ it under the terms of the GNU General Public License as published by
22+ the Free Software Foundation, either version 3 of the License, or
23+ (at your option) any later version.
24+
25+ Etripator is distributed in the hope that it will be useful,
26+ but WITHOUT ANY WARRANTY; without even the implied warranty of
27+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+ GNU General Public License for more details.
29+
30+ You should have received a copy of the GNU General Public License
31+ along with Etripator. If not, see <http://www.gnu.org/licenses/>.
32+
33+ ¬°¤*,¸¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸
34+ ¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯¬°¤*,¸_¸,*¤°¬°¤*,¸,*¤°¬¯
35+ */
36+ #include <munit.h>
37+
38+ #include "../ipl.c"
39+
40+ #include "message.h"
41+ #include "message/console.h"
42+
43+ static uint8_t g_hcd8004_ipl [] = {
44+ 0x00 , 0x00 , 0x02 , 0x04 , 0x00 , 0x40 , 0x00 , 0x40 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x00 , 0x00 , 0x00 ,
45+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
46+ 0x50 , 0x43 , 0x20 , 0x45 , 0x6E , 0x67 , 0x69 , 0x6E , 0x65 , 0x20 , 0x43 , 0x44 , 0x2D , 0x52 , 0x4F , 0x4D ,
47+ 0x20 , 0x53 , 0x59 , 0x53 , 0x54 , 0x45 , 0x4D , 0x00 , 0x43 , 0x6F , 0x70 , 0x79 , 0x72 , 0x69 , 0x67 , 0x68 ,
48+ 0x74 , 0x20 , 0x48 , 0x55 , 0x44 , 0x53 , 0x4F , 0x4E , 0x20 , 0x53 , 0x4F , 0x46 , 0x54 , 0x20 , 0x2F , 0x20 ,
49+ 0x4E , 0x45 , 0x43 , 0x20 , 0x48 , 0x6F , 0x6D , 0x65 , 0x20 , 0x45 , 0x6C , 0x65 , 0x63 , 0x74 , 0x72 , 0x6F ,
50+ 0x6E , 0x69 , 0x63 , 0x73 , 0x2C , 0x4C , 0x74 , 0x64 , 0x2E , 0x00 , 0x53 , 0x70 , 0x61 , 0x63 , 0x65 , 0x20 ,
51+ 0x41 , 0x64 , 0x76 , 0x65 , 0x6E , 0x74 , 0x75 , 0x72 , 0x65 , 0x20 , 0x43 , 0x4F , 0x42 , 0x52 , 0x41 , 0x20 ,
52+ };
53+
54+ void * setup (const MunitParameter params [] __attribute__((unused )), void * user_data __attribute__((unused ))) {
55+ message_printer_init ();
56+ console_message_printer_init ();
57+ return NULL ;
58+ }
59+
60+ void tear_down (void * fixture __attribute__((unused ))) {
61+ message_printer_destroy ();
62+ }
63+
64+ MunitResult ipl_read_test (const MunitParameter params [] __attribute__((unused )), void * fixture __attribute__((unused ))) {
65+ IPL ipl = {0 };
66+ const char * filename = "data/HCD8004.ipl" ;
67+
68+ FILE * in = fmemopen (g_hcd8004_ipl , sizeof (g_hcd8004_ipl ), "r" );
69+
70+ munit_assert_not_null (in );
71+ munit_assert_true (ipl_read_header (& ipl , in , filename ));
72+ munit_assert_int (fclose (in ), = = , 0 );
73+
74+ munit_assert_uint8 (ipl .load_start_record [0 ], = = , 0x00U );
75+ munit_assert_uint8 (ipl .load_start_record [1 ], = = , 0x00U );
76+ munit_assert_uint8 (ipl .load_start_record [2 ], = = , 0x02U );
77+
78+ munit_assert_uint8 (ipl .load_sector_count , = = , 0x04U );
79+
80+ munit_assert_uint8 (ipl .load_store_address [0 ], = = , 0x00U );
81+ munit_assert_uint8 (ipl .load_store_address [1 ], = = , 0x40U );
82+
83+ munit_assert_uint8 (ipl .load_exec_address [0 ], = = , 0x00U );
84+ munit_assert_uint8 (ipl .load_exec_address [1 ], = = , 0x40U );
85+
86+ munit_assert_uint8 (ipl .mpr [0 ], = = , 0x00U );
87+ munit_assert_uint8 (ipl .mpr [1 ], = = , 0x01U );
88+ munit_assert_uint8 (ipl .mpr [2 ], = = , 0x02U );
89+ munit_assert_uint8 (ipl .mpr [3 ], = = , 0x03U );
90+ munit_assert_uint8 (ipl .mpr [4 ], = = , 0x04U );
91+
92+ munit_assert_uint8 (ipl .opening_mode , = = , 0x00U );
93+
94+ munit_assert_uint8 (ipl .opening_gfx_record [0 ], = = , 0x00U );
95+ munit_assert_uint8 (ipl .opening_gfx_record [1 ], = = , 0x00U );
96+ munit_assert_uint8 (ipl .opening_gfx_record [2 ], = = , 0x00U );
97+
98+ munit_assert_uint8 (ipl .opening_gfx_sector_count , = = , 0x00U );
99+
100+ munit_assert_uint8 (ipl .opening_gfx_read_address [0 ], = = , 0x00U );
101+ munit_assert_uint8 (ipl .opening_gfx_read_address [1 ], = = , 0x00U );
102+
103+ munit_assert_uint8 (ipl .opening_adpcm_record [0 ], = = , 0x00U );
104+ munit_assert_uint8 (ipl .opening_adpcm_record [1 ], = = , 0x00U );
105+ munit_assert_uint8 (ipl .opening_adpcm_record [2 ], = = , 0x00U );
106+
107+ munit_assert_uint8 (ipl .opening_adpcm_sector_count , = = , 0x00U );
108+
109+ munit_assert_uint8 (ipl .opening_adpcm_sampling_rate , = = , 0x00U );
110+
111+ for (unsigned int i = 0 ; i < 7 ; i ++ ) {
112+ munit_assert_uint8 (ipl .reserved [i ], = = , 0x00U );
113+ }
114+
115+ munit_assert_memory_equal (24U , ipl .id , "PC Engine CD-ROM SYSTEM" );
116+
117+ munit_assert_memory_equal (50U , ipl .legal , "Copyright HUDSON SOFT / NEC Home Electronics,Ltd." );
118+
119+ munit_assert_memory_equal (16U , ipl .program_name , "Space Adventure " );
120+
121+ munit_assert_memory_equal (6U , ipl .extra , "COBRA " );
122+
123+ return MUNIT_OK ;
124+ }
125+
126+ static MunitTest g_ipl_tests [] = {
127+ { "/read" , ipl_read_test , setup , tear_down , MUNIT_TEST_OPTION_NONE , NULL },
128+ { NULL , NULL , NULL , NULL , MUNIT_TEST_OPTION_NONE , NULL }
129+ };
130+
131+ static const MunitSuite g_ipl_test_suite = {
132+ "Label test suite" , g_ipl_tests , NULL , 1 , MUNIT_SUITE_OPTION_NONE
133+ };
134+
135+ int main (int argc , char * const * argv ) {
136+ return munit_suite_main (& g_ipl_test_suite , NULL , argc , argv );
137+ }
0 commit comments