@@ -1177,14 +1177,14 @@ void BlitterMidsummer2(void)
11771177
11781178 // Line states passed in via the command register
11791179
1180- bool srcen = (SRCEN ), srcenx = (SRCENX ), srcenz = (SRCENZ ),
1180+ const bool srcen = (SRCEN ), srcenx = (SRCENX ), srcenz = (SRCENZ ),
11811181 dsten = (DSTEN ), dstenz = (DSTENZ ), dstwrz = (DSTWRZ ), clip_a1 = (CLIPA1 ),
11821182 upda1 = (UPDA1 ), upda1f = (UPDA1F ), upda2 = (UPDA2 ), dsta2 = (DSTA2 ),
11831183 gourd = (GOURD ), gourz = (GOURZ ), topben = (TOPBEN ), topnen = (TOPNEN ),
11841184 patdsel = (PATDSEL ), adddsel = (ADDDSEL ), cmpdst = (CMPDST ), bcompen = (BCOMPEN ),
11851185 dcompen = (DCOMPEN ), bkgwren = (BKGWREN ), srcshade = (SRCSHADE );
11861186
1187- uint8_t zmode = (cmd .WORD & 0x01C0000 ) >> 18 , lfufunc = (cmd .WORD & 0x1E00000 ) >> 21 ;
1187+ const uint8_t zmode = (cmd .WORD & 0x01C0000 ) >> 18 , lfufunc = (cmd .WORD & 0x1E00000 ) >> 21 ;
11881188 //Missing: BUSHI
11891189 //Where to find various lines:
11901190 // clip_a1 -> inner
@@ -1219,36 +1219,35 @@ void BlitterMidsummer2(void)
12191219
12201220 // Various registers set up by user
12211221
1222- uint16_t ocount = GET16 (blitter_ram , PIXLINECOUNTER );
1223- uint8_t a1_pitch = blitter_ram [A1_FLAGS + 3 ] & 0x03 ;
1224- uint8_t a2_pitch = blitter_ram [A2_FLAGS + 3 ] & 0x03 ;
1225- uint8_t a1_pixsize = (blitter_ram [A1_FLAGS + 3 ] & 0x38 ) >> 3 ;
1226- uint8_t a2_pixsize = (blitter_ram [A2_FLAGS + 3 ] & 0x38 ) >> 3 ;
1227- uint8_t a1_zoffset = (GET16 (blitter_ram , A1_FLAGS + 2 ) >> 6 ) & 0x07 ;
1228- uint8_t a2_zoffset = (GET16 (blitter_ram , A2_FLAGS + 2 ) >> 6 ) & 0x07 ;
1229- uint8_t a1_width = (blitter_ram [A1_FLAGS + 2 ] >> 1 ) & 0x3F ;
1230- uint8_t a2_width = (blitter_ram [A2_FLAGS + 2 ] >> 1 ) & 0x3F ;
1231- uint8_t a1addx = blitter_ram [A1_FLAGS + 1 ] & 0x03 , a2addx = blitter_ram [A2_FLAGS + 1 ] & 0x03 ;
1232- bool a1addy = blitter_ram [A1_FLAGS + 1 ] & 0x04 , a2addy = blitter_ram [A2_FLAGS + 1 ] & 0x04 ;
1233- bool a1xsign = blitter_ram [A1_FLAGS + 1 ] & 0x08 , a2xsign = blitter_ram [A2_FLAGS + 1 ] & 0x08 ;
1234- bool a1ysign = blitter_ram [A1_FLAGS + 1 ] & 0x10 , a2ysign = blitter_ram [A2_FLAGS + 1 ] & 0x10 ;
1235- uint32_t a1_base = GET32 (blitter_ram , A1_BASE ) & 0xFFFFFFF8 ; // Phrase aligned by ignoring bottom 3 bits
1236- uint32_t a2_base = GET32 (blitter_ram , A2_BASE ) & 0xFFFFFFF8 ;
1237-
1238- uint16_t a1_win_x = GET16 (blitter_ram , A1_CLIP + 2 ) & 0x7FFF ;
1239- uint16_t a1_win_y = GET16 (blitter_ram , A1_CLIP + 0 ) & 0x7FFF ;
1222+ uint16_t ocount = GET16 (blitter_ram , PIXLINECOUNTER );
1223+ const uint8_t a1_pitch = blitter_ram [A1_FLAGS + 3 ] & 0x03 ;
1224+ const uint8_t a2_pitch = blitter_ram [A2_FLAGS + 3 ] & 0x03 ;
1225+ const uint8_t a1_pixsize = (blitter_ram [A1_FLAGS + 3 ] & 0x38 ) >> 3 ;
1226+ const uint8_t a2_pixsize = (blitter_ram [A2_FLAGS + 3 ] & 0x38 ) >> 3 ;
1227+ const uint8_t a1_zoffset = (GET16 (blitter_ram , A1_FLAGS + 2 ) >> 6 ) & 0x07 ;
1228+ const uint8_t a2_zoffset = (GET16 (blitter_ram , A2_FLAGS + 2 ) >> 6 ) & 0x07 ;
1229+ const uint8_t a1_width = (blitter_ram [A1_FLAGS + 2 ] >> 1 ) & 0x3F ;
1230+ const uint8_t a2_width = (blitter_ram [A2_FLAGS + 2 ] >> 1 ) & 0x3F ;
1231+ const uint8_t a1addx = blitter_ram [A1_FLAGS + 1 ] & 0x03 , a2addx = blitter_ram [A2_FLAGS + 1 ] & 0x03 ;
1232+ bool a1addy = blitter_ram [A1_FLAGS + 1 ] & 0x04 , a2addy = blitter_ram [A2_FLAGS + 1 ] & 0x04 ;const bool a1xsign = blitter_ram [A1_FLAGS + 1 ] & 0x08 , a2xsign = blitter_ram [A2_FLAGS + 1 ] & 0x08 ;
1233+ const bool a1ysign = blitter_ram [A1_FLAGS + 1 ] & 0x10 , a2ysign = blitter_ram [A2_FLAGS + 1 ] & 0x10 ;
1234+ const uint32_t a1_base = GET32 (blitter_ram , A1_BASE ) & 0xFFFFFFF8 ; // Phrase aligned by ignoring bottom 3 bits
1235+ const uint32_t a2_base = GET32 (blitter_ram , A2_BASE ) & 0xFFFFFFF8 ;
1236+
1237+ const uint16_t a1_win_x = GET16 (blitter_ram , A1_CLIP + 2 ) & 0x7FFF ;
1238+ const uint16_t a1_win_y = GET16 (blitter_ram , A1_CLIP + 0 ) & 0x7FFF ;
12401239 int16_t a1_x = (int16_t )GET16 (blitter_ram , A1_PIXEL + 2 );
12411240 int16_t a1_y = (int16_t )GET16 (blitter_ram , A1_PIXEL + 0 );
1242- int16_t a1_step_x = (int16_t )GET16 (blitter_ram , A1_STEP + 2 );
1243- int16_t a1_step_y = (int16_t )GET16 (blitter_ram , A1_STEP + 0 );
1244- uint16_t a1_stepf_x = GET16 (blitter_ram , A1_FSTEP + 2 );
1245- uint16_t a1_stepf_y = GET16 (blitter_ram , A1_FSTEP + 0 );
1241+ const int16_t a1_step_x = (int16_t )GET16 (blitter_ram , A1_STEP + 2 );
1242+ const int16_t a1_step_y = (int16_t )GET16 (blitter_ram , A1_STEP + 0 );
1243+ const uint16_t a1_stepf_x = GET16 (blitter_ram , A1_FSTEP + 2 );
1244+ const uint16_t a1_stepf_y = GET16 (blitter_ram , A1_FSTEP + 0 );
12461245 uint16_t a1_frac_x = GET16 (blitter_ram , A1_FPIXEL + 2 );
12471246 uint16_t a1_frac_y = GET16 (blitter_ram , A1_FPIXEL + 0 );
1248- int16_t a1_inc_x = (int16_t )GET16 (blitter_ram , A1_INC + 2 );
1249- int16_t a1_inc_y = (int16_t )GET16 (blitter_ram , A1_INC + 0 );
1250- uint16_t a1_incf_x = GET16 (blitter_ram , A1_FINC + 2 );
1251- uint16_t a1_incf_y = GET16 (blitter_ram , A1_FINC + 0 );
1247+ const int16_t a1_inc_x = (int16_t )GET16 (blitter_ram , A1_INC + 2 );
1248+ const int16_t a1_inc_y = (int16_t )GET16 (blitter_ram , A1_INC + 0 );
1249+ const uint16_t a1_incf_x = GET16 (blitter_ram , A1_FINC + 2 );
1250+ const uint16_t a1_incf_y = GET16 (blitter_ram , A1_FINC + 0 );
12521251
12531252 int16_t a2_x = (int16_t )GET16 (blitter_ram , A2_PIXEL + 2 );
12541253 int16_t a2_y = (int16_t )GET16 (blitter_ram , A2_PIXEL + 0 );
@@ -1258,8 +1257,8 @@ void BlitterMidsummer2(void)
12581257 uint16_t a2_mask_y = GET16 (blitter_ram , A2_MASK + 0 );
12591258 uint32_t collision = GET32 (blitter_ram , COLLISIONCTRL );// 0=RESUME, 1=ABORT, 2=STOPEN
12601259#endif
1261- int16_t a2_step_x = (int16_t )GET16 (blitter_ram , A2_STEP + 2 );
1262- int16_t a2_step_y = (int16_t )GET16 (blitter_ram , A2_STEP + 0 );
1260+ const int16_t a2_step_x = (int16_t )GET16 (blitter_ram , A2_STEP + 2 );
1261+ const int16_t a2_step_y = (int16_t )GET16 (blitter_ram , A2_STEP + 0 );
12631262
12641263 uint64_t srcd1 = GET64 (blitter_ram , SRCDATA );
12651264 uint64_t srcd2 = 0 ;
@@ -1271,7 +1270,7 @@ void BlitterMidsummer2(void)
12711270 uint64_t dstz = GET64 (blitter_ram , DSTZ );
12721271 uint32_t zinc = GET32 (blitter_ram , ZINC );
12731272
1274- uint8_t pixsize = (dsta2 ? a2_pixsize : a1_pixsize ); // From ACONTROL
1273+ const uint8_t pixsize = (dsta2 ? a2_pixsize : a1_pixsize ); // From ACONTROL
12751274
12761275 bool phrase_mode ;
12771276 uint16_t a1FracCInX = 0 , a1FracCInY = 0 ;
@@ -1367,24 +1366,15 @@ void BlitterMidsummer2(void)
13671366
13681367 // INITIALIZE INTENSITY INTEGER
13691368
1370- if (init_if )
1371- init_iii = true;
1372- else
1373- init_iii = false;
1369+ init_iii = init_if ;
13741370
13751371 // INITIALIZE Z FRACTION
13761372
1377- if (init_ii && gourz )
1378- init_zfi = true;
1379- else
1380- init_zfi = false;
1373+ init_zfi = (init_ii && gourz );
13811374
13821375 // INITIALIZE Z INTEGER
13831376
1384- if (init_zf )
1385- init_zii = true;
1386- else
1387- init_zii = false;
1377+ init_zii = init_zf ;
13881378
13891379 // Here we move the fooi into their foo counterparts in order to simulate the moving
13901380 // of data into the various FDSYNCs... Each time we loop we simulate one clock cycle...
@@ -1740,9 +1730,9 @@ A2ptrldi := NAN2 (a2ptrldi, a2update\, a2pldt);*/
17401730 + dwrite . srcshade
17411731 */
17421732 daddasel = ((dwrite && gourd ) || (dzwrite && gourz ) || istepadd || zstepfadd
1743- || init_if || init_ii || init_zf || init_zi ? 0x01 : 0x00 );
1744- daddasel |= ((dzwrite && gourz ) || zstepadd || zstepfadd ? 0x02 : 0x00 );
1745- daddasel |= (((gourd || gourz ) && !(init_if || init_ii || init_zf || init_zi ))
1733+ || init_if || init_ii || init_zf || init_zi ? 0x01 : 0x00 )
1734+ | ((dzwrite && gourz ) || zstepadd || zstepfadd ? 0x02 : 0x00 )
1735+ | (((gourd || gourz ) && !(init_if || init_ii || init_zf || init_zi ))
17461736 || (dwrite && srcshade ) ? 0x04 : 0x00 );
17471737 /* Data adder control, input B selection
17481738 0000 Source data
@@ -1772,11 +1762,11 @@ A2ptrldi := NAN2 (a2ptrldi, a2update\, a2pldt);*/
17721762 Bit 3 = istepadd + istepfadd + zstepadd + zstepfadd
17731763 */
17741764 daddbsel = ((dwrite && gourd ) || (dzwrite && gourz ) || (dwrite && srcshade )
1775- || istepadd || zstepadd || init_if || init_ii || init_zf || init_zi ? 0x01 : 0x00 );
1776- daddbsel |= ((dzwrite && gourz ) || zstepadd || zstepfadd ? 0x02 : 0x00 );
1777- daddbsel |= ((dwrite && gourd ) || (dzwrite && gourz ) || (dwrite && srcshade )
1778- || istepadd || istepfadd || zstepadd || zstepfadd ? 0x04 : 0x00 );
1779- daddbsel |= (istepadd && istepfadd && zstepadd && zstepfadd ? 0x08 : 0x00 );
1765+ || istepadd || zstepadd || init_if || init_ii || init_zf || init_zi ? 0x01 : 0x00 )
1766+ | ((dzwrite && gourz ) || zstepadd || zstepfadd ? 0x02 : 0x00 )
1767+ | ((dwrite && gourd ) || (dzwrite && gourz ) || (dwrite && srcshade )
1768+ || istepadd || istepfadd || zstepadd || zstepfadd ? 0x04 : 0x00 )
1769+ | (istepadd && istepfadd && zstepadd && zstepfadd ? 0x08 : 0x00 );
17801770 /* Data adder mode control
17811771 000 16-bit normal add
17821772 001 16-bit saturating add with carry
@@ -2841,27 +2831,27 @@ Patdhi := JOIN (patdhi, patd[32..63]);*/
28412831
28422832/*Lfu := LFU (lfu[0..1], srcdlo, srcdhi, dstdlo, dstdhi, lfu_func[0..3]);*/
28432833////////////////////////////////////// C++ CODE //////////////////////////////////////
2844- uint64_t funcmask [2 ] = { 0 , 0xFFFFFFFFFFFFFFFFLL };
2845- uint64_t func0 = funcmask [lfu_func & 0x01 ];
2846- uint64_t func1 = funcmask [(lfu_func >> 1 ) & 0x01 ];
2847- uint64_t func2 = funcmask [(lfu_func >> 2 ) & 0x01 ];
2848- uint64_t func3 = funcmask [(lfu_func >> 3 ) & 0x01 ];
2849- uint64_t lfu = (~srcd & ~dstd & func0 ) | (~srcd & dstd & func1 ) | (srcd & ~dstd & func2 ) | (srcd & dstd & func3 );
2834+ static const uint64_t funcmask [2 ] = { 0 , 0xFFFFFFFFFFFFFFFFLL };
2835+ const uint64_t func0 = funcmask [lfu_func & 0x01 ];
2836+ const uint64_t func1 = funcmask [(lfu_func >> 1 ) & 0x01 ];
2837+ const uint64_t func2 = funcmask [(lfu_func >> 2 ) & 0x01 ];
2838+ const uint64_t func3 = funcmask [(lfu_func >> 3 ) & 0x01 ];
2839+ const uint64_t lfu = (~srcd & ~dstd & func0 ) | (~srcd & dstd & func1 ) | (srcd & ~dstd & func2 ) | (srcd & dstd & func3 );
28502840 bool mir_bit , mir_byte ;
28512841 uint16_t masku ;
28522842 uint8_t e_coarse , e_fine ;
28532843 uint8_t s_coarse , s_fine ;
28542844 uint16_t maskt ;
2855- uint8_t decl38e [2 ][8 ] = { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF },
2845+ static const uint8_t decl38e [2 ][8 ] = { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF },
28562846 { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } };
2857- uint8_t dech38 [8 ] = { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 };
2858- uint8_t dech38el [2 ][8 ] = { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 },
2847+ static const uint8_t dech38 [8 ] = { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 };
2848+ static const uint8_t dech38el [2 ][8 ] = { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 },
28592849 { 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 } };
28602850 int en ;
28612851 Bits64 cmpd ;
28622852 uint8_t dbinht ;
28632853 uint16_t addq [4 ];
2864- uint8_t initcin [4 ] = { 0 , 0 , 0 , 0 };
2854+ static const uint8_t initcin [4 ] = { 0 , 0 , 0 , 0 };
28652855 uint16_t mask ;
28662856 uint64_t dmux [4 ];
28672857 uint64_t ddat ;
0 commit comments