diff --git a/src/test/kc/examples/nes/nes-demo.c b/src/test/kc/examples/nes/nes-demo.c index f29a64af9..867e76100 100644 --- a/src/test/kc/examples/nes/nes-demo.c +++ b/src/test/kc/examples/nes/nes-demo.c @@ -71,22 +71,6 @@ interrupt(hardware_stack) void vblank() { } -// move the Luigi sprites right -void moveLuigiRight() { - OAM_BUFFER[0x03]++; - OAM_BUFFER[0x07]++; - OAM_BUFFER[0x0b]++; - OAM_BUFFER[0x0f]++; -} - -// move the Luigi sprites left -void moveLuigiLeft() { - OAM_BUFFER[0x03]--; - OAM_BUFFER[0x07]--; - OAM_BUFFER[0x0b]--; - OAM_BUFFER[0x0f]--; -} - // Copy palette values to PPU void initPaletteData() { // Reset the high/low latch to "high" @@ -100,16 +84,6 @@ void initPaletteData() { PPU->PPUDATA = PALETTE[i]; } -// OAM (Object Attribute Memory) Buffer -// Will be transfered to the PPU via DMA -char * const OAM_BUFFER = 0x0200; - -// Initialize OAM (Object Attribute Memory) Buffer -void initSpriteData() { - for(char i=0;i(const nomodify byte*) OAM_BUFFER + [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify struct ObjectAttribute*) OAM_BUFFER [50] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) ← (byte) 1 [51] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) ← (byte) 0 [52] (byte~) vblank::$1 ← *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) & (byte) 1 @@ -127,10 +125,10 @@ vblank::@return: scope:[vblank] from vblank::@1 vblank::@3 (void()) moveLuigiLeft() moveLuigiLeft: scope:[moveLuigiLeft] from vblank::@3 - [61] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 3) - [62] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 7) - [63] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $b) - [64] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $f) + [61] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) + [62] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) + [63] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) + [64] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) to:moveLuigiLeft::@return moveLuigiLeft::@return: scope:[moveLuigiLeft] from moveLuigiLeft [65] return @@ -138,10 +136,10 @@ moveLuigiLeft::@return: scope:[moveLuigiLeft] from moveLuigiLeft (void()) moveLuigiRight() moveLuigiRight: scope:[moveLuigiRight] from vblank::@2 - [66] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 3) - [67] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 7) - [68] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $b) - [69] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $f) + [66] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) + [67] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) + [68] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) + [69] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) to:moveLuigiRight::@return moveLuigiRight::@return: scope:[moveLuigiRight] from moveLuigiRight [70] return diff --git a/src/test/ref/examples/nes/nes-demo.log b/src/test/ref/examples/nes/nes-demo.log index a90a04271..030cdfaf5 100644 --- a/src/test/ref/examples/nes/nes-demo.log +++ b/src/test/ref/examples/nes/nes-demo.log @@ -1,32 +1,8 @@ -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER -Resolved forward reference OAM_BUFFER to (const nomodify byte*) OAM_BUFFER +Resolved forward reference OAM_BUFFER to (const nomodify struct ObjectAttribute*) OAM_BUFFER Resolved forward reference PALETTE to (const byte*) PALETTE Resolved forward reference PALETTE to (const byte*) PALETTE -Resolved forward reference SPRITES to (const byte*) SPRITES -Resolved forward reference SPRITES to (const byte*) SPRITES +Resolved forward reference SPRITES to (const struct ObjectAttribute*) SPRITES +Resolved forward reference SPRITES to (const struct ObjectAttribute*) SPRITES Inlined call call disableVideoOutput Inlined call call disableAudioOutput Inlined call call clearVBlankFlag @@ -125,7 +101,7 @@ vblank: scope:[vblank] from (byte*~) vblank::$13 ← (byte*)(const struct RICOH_2C02*) PPU (byte*~) vblank::$7 ← (byte*~) vblank::$13 + (const byte) OFFSET_STRUCT_RICOH_2C02_OAMADDR *((byte*~) vblank::$7) ← (number) 0 - (byte~) vblank::$0 ← > (const nomodify byte*) OAM_BUFFER + (byte~) vblank::$0 ← > (const nomodify struct ObjectAttribute*) OAM_BUFFER (byte*~) vblank::$14 ← (byte*)(const struct RICOH_2A03*) APU (byte*~) vblank::$8 ← (byte*~) vblank::$14 + (const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA *((byte*~) vblank::$8) ← (byte~) vblank::$0 @@ -164,28 +140,6 @@ vblank::@return: scope:[vblank] from vblank::@1 vblank::@5 return to:@return -(void()) moveLuigiRight() -moveLuigiRight: scope:[moveLuigiRight] from vblank::@2 - *((const nomodify byte*) OAM_BUFFER + (number) 3) ← ++ *((const nomodify byte*) OAM_BUFFER + (number) 3) - *((const nomodify byte*) OAM_BUFFER + (number) 7) ← ++ *((const nomodify byte*) OAM_BUFFER + (number) 7) - *((const nomodify byte*) OAM_BUFFER + (number) $b) ← ++ *((const nomodify byte*) OAM_BUFFER + (number) $b) - *((const nomodify byte*) OAM_BUFFER + (number) $f) ← ++ *((const nomodify byte*) OAM_BUFFER + (number) $f) - to:moveLuigiRight::@return -moveLuigiRight::@return: scope:[moveLuigiRight] from moveLuigiRight - return - to:@return - -(void()) moveLuigiLeft() -moveLuigiLeft: scope:[moveLuigiLeft] from vblank::@3 - *((const nomodify byte*) OAM_BUFFER + (number) 3) ← -- *((const nomodify byte*) OAM_BUFFER + (number) 3) - *((const nomodify byte*) OAM_BUFFER + (number) 7) ← -- *((const nomodify byte*) OAM_BUFFER + (number) 7) - *((const nomodify byte*) OAM_BUFFER + (number) $b) ← -- *((const nomodify byte*) OAM_BUFFER + (number) $b) - *((const nomodify byte*) OAM_BUFFER + (number) $f) ← -- *((const nomodify byte*) OAM_BUFFER + (number) $f) - to:moveLuigiLeft::@return -moveLuigiLeft::@return: scope:[moveLuigiLeft] from moveLuigiLeft - return - to:@return - (void()) initPaletteData() initPaletteData: scope:[initPaletteData] from main::@4 asm { ldaPPU_PPUSTATUS } @@ -214,21 +168,49 @@ initPaletteData::@return: scope:[initPaletteData] from initPaletteData::@1 return to:@return +(void()) moveLuigiRight() +moveLuigiRight: scope:[moveLuigiRight] from vblank::@2 + (number~) moveLuigiRight::$5 ← (number) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE + *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiRight::$5) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiRight::$5) + (number~) moveLuigiRight::$7 ← (number) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE + *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiRight::$7) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiRight::$7) + (number~) moveLuigiRight::$9 ← (number) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE + *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiRight::$9) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiRight::$9) + (number~) moveLuigiRight::$11 ← (number) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE + *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiRight::$11) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiRight::$11) + to:moveLuigiRight::@return +moveLuigiRight::@return: scope:[moveLuigiRight] from moveLuigiRight + return + to:@return + +(void()) moveLuigiLeft() +moveLuigiLeft: scope:[moveLuigiLeft] from vblank::@3 + (number~) moveLuigiLeft::$5 ← (number) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE + *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiLeft::$5) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiLeft::$5) + (number~) moveLuigiLeft::$7 ← (number) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE + *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiLeft::$7) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiLeft::$7) + (number~) moveLuigiLeft::$9 ← (number) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE + *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiLeft::$9) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiLeft::$9) + (number~) moveLuigiLeft::$11 ← (number) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE + *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiLeft::$11) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (number~) moveLuigiLeft::$11) + to:moveLuigiLeft::@return +moveLuigiLeft::@return: scope:[moveLuigiLeft] from moveLuigiLeft + return + to:@return + (void()) initSpriteData() initSpriteData: scope:[initSpriteData] from main::@5 (byte) initSpriteData::i#0 ← (byte) 0 to:initSpriteData::@1 -initSpriteData::@1: scope:[initSpriteData] from initSpriteData initSpriteData::@2 - (byte) initSpriteData::i#2 ← phi( initSpriteData/(byte) initSpriteData::i#0 initSpriteData::@2/(byte) initSpriteData::i#1 ) - (byte~) initSpriteData::$0 ← sizeof (const byte*) SPRITES - (bool~) initSpriteData::$1 ← (byte) initSpriteData::i#2 < (byte~) initSpriteData::$0 - if((bool~) initSpriteData::$1) goto initSpriteData::@2 +initSpriteData::@1: scope:[initSpriteData] from initSpriteData initSpriteData::@1 + (byte) initSpriteData::i#2 ← phi( initSpriteData/(byte) initSpriteData::i#0 initSpriteData::@1/(byte) initSpriteData::i#1 ) + (byte*~) initSpriteData::$2 ← (byte*)(const struct ObjectAttribute*) SPRITES + *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((byte*~) initSpriteData::$2 + (byte) initSpriteData::i#2) + (byte) initSpriteData::i#1 ← ++ (byte) initSpriteData::i#2 + (byte~) initSpriteData::$0 ← sizeof (const struct ObjectAttribute*) SPRITES + (bool~) initSpriteData::$1 ← (byte) initSpriteData::i#1 != (byte~) initSpriteData::$0 + if((bool~) initSpriteData::$1) goto initSpriteData::@1 to:initSpriteData::@return -initSpriteData::@2: scope:[initSpriteData] from initSpriteData::@1 - (byte) initSpriteData::i#3 ← phi( initSpriteData::@1/(byte) initSpriteData::i#2 ) - *((const nomodify byte*) OAM_BUFFER + (byte) initSpriteData::i#3) ← *((const byte*) SPRITES + (byte) initSpriteData::i#3) - (byte) initSpriteData::i#1 ← ++ (byte) initSpriteData::i#3 - to:initSpriteData::@1 initSpriteData::@return: scope:[initSpriteData] from initSpriteData::@1 return to:@return @@ -251,7 +233,8 @@ SYMBOL TABLE SSA .segmentout [ segments="ProgramRom" ] .segmentout [ segments="CharacterRom" ] }} -(const nomodify byte*) OAM_BUFFER = (byte*)(number) $200 +(const nomodify struct ObjectAttribute*) OAM_BUFFER = (struct ObjectAttribute*)(number) $200 +(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X = (byte) 3 (const byte) OFFSET_STRUCT_RICOH_2A03_DMC_FREQ = (byte) $10 (const byte) OFFSET_STRUCT_RICOH_2A03_JOY1 = (byte) $16 (const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA = (byte) $14 @@ -261,6 +244,10 @@ SYMBOL TABLE SSA (const byte) OFFSET_STRUCT_RICOH_2C02_PPUDATA = (byte) 7 (const byte) OFFSET_STRUCT_RICOH_2C02_PPUMASK = (byte) 1 (const byte) OFFSET_STRUCT_RICOH_2C02_PPUSTATUS = (byte) 2 +(byte) ObjectAttribute::attributes +(byte) ObjectAttribute::tile +(byte) ObjectAttribute::x +(byte) ObjectAttribute::y (const byte*) PALETTE[(number) $20] = { (byte) $f, (byte) $31, (byte) $32, (byte) $33, (byte) $f, (byte) $35, (byte) $36, (byte) $37, (byte) $f, (byte) $39, (byte) $3a, (byte) $3b, (byte) $f, (byte) $3d, (byte) $3e, (byte) $f, (byte) $f, (byte) $1c, (byte) $15, (byte) $14, (byte) $f, (byte) 2, (byte) $38, (byte) $3c, (byte) $f, (byte) $30, (byte) $37, (byte) $1a, (byte) $f, (byte) $f, (byte) $f, (byte) $f } (const struct RICOH_2C02*) PPU = (struct RICOH_2C02*)(number) $2000 (const nomodify byte*) PPU_PALETTE = (byte*)(number) $3f00 @@ -297,7 +284,8 @@ SYMBOL TABLE SSA (byte) RICOH_2C02::PPUMASK (byte) RICOH_2C02::PPUSCROLL (volatile byte) RICOH_2C02::PPUSTATUS loadstore -(const byte*) SPRITES[] = { (byte) $80, (byte) $36, (byte) 2, (byte) $80, (byte) $80, (byte) $37, (byte) 2, (byte) $88, (byte) $88, (byte) $38, (byte) 2, (byte) $80, (byte) $88, (byte) $39, (byte) 2, (byte) $88 } +(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE = (byte) 4 +(const struct ObjectAttribute*) SPRITES[] = { { y: (byte) $80, tile: (byte) $36, attributes: (byte) 2, x: (byte) $80 }, { y: (byte) $80, tile: (byte) $37, attributes: (byte) 2, x: (byte) $88 }, { y: (byte) $88, tile: (byte) $38, attributes: (byte) 2, x: (byte) $80 }, { y: (byte) $88, tile: (byte) $39, attributes: (byte) 2, x: (byte) $88 } } (const byte*) TILES[] = kickasm {{ .import binary "smb1_chr.bin" }} (const to_nomodify void()**) VECTORS[] = { &interrupt(HARDWARE_STACK)(void()) vblank(), &(void()) main(), (void()*)(number) 0 } @@ -321,14 +309,13 @@ SYMBOL TABLE SSA (void()) initSpriteData() (byte~) initSpriteData::$0 (bool~) initSpriteData::$1 +(byte*~) initSpriteData::$2 (label) initSpriteData::@1 -(label) initSpriteData::@2 (label) initSpriteData::@return (byte) initSpriteData::i (byte) initSpriteData::i#0 (byte) initSpriteData::i#1 (byte) initSpriteData::i#2 -(byte) initSpriteData::i#3 (void()) main() (bool~) main::$8 (bool~) main::$9 @@ -372,8 +359,16 @@ SYMBOL TABLE SSA (bool~) main::waitForVBlank2_$4 (label) main::waitForVBlank2_@1 (void()) moveLuigiLeft() +(number~) moveLuigiLeft::$11 +(number~) moveLuigiLeft::$5 +(number~) moveLuigiLeft::$7 +(number~) moveLuigiLeft::$9 (label) moveLuigiLeft::@return (void()) moveLuigiRight() +(number~) moveLuigiRight::$11 +(number~) moveLuigiRight::$5 +(number~) moveLuigiRight::$7 +(number~) moveLuigiRight::$9 (label) moveLuigiRight::@return interrupt(HARDWARE_STACK)(void()) vblank() (byte~) vblank::$0 @@ -440,22 +435,22 @@ Adding number conversion cast (unumber) 0 in (bool~) vblank::$19 ← (number) 0 Adding number conversion cast (unumber) 1 in (number~) vblank::$3 ← *((byte*~) vblank::$12) & (number) 1 Adding number conversion cast (unumber) vblank::$3 in (number~) vblank::$3 ← *((byte*~) vblank::$12) & (unumber)(number) 1 Adding number conversion cast (unumber) 0 in (bool~) vblank::$20 ← (number) 0 != (unumber~) vblank::$3 -Adding number conversion cast (unumber) 3 in *((const nomodify byte*) OAM_BUFFER + (number) 3) ← ++ *((const nomodify byte*) OAM_BUFFER + (number) 3) -Adding number conversion cast (unumber) 3 in *((const nomodify byte*) OAM_BUFFER + (number) 3) ← ++ *((const nomodify byte*) OAM_BUFFER + (unumber)(number) 3) -Adding number conversion cast (unumber) 7 in *((const nomodify byte*) OAM_BUFFER + (number) 7) ← ++ *((const nomodify byte*) OAM_BUFFER + (number) 7) -Adding number conversion cast (unumber) 7 in *((const nomodify byte*) OAM_BUFFER + (number) 7) ← ++ *((const nomodify byte*) OAM_BUFFER + (unumber)(number) 7) -Adding number conversion cast (unumber) $b in *((const nomodify byte*) OAM_BUFFER + (number) $b) ← ++ *((const nomodify byte*) OAM_BUFFER + (number) $b) -Adding number conversion cast (unumber) $b in *((const nomodify byte*) OAM_BUFFER + (number) $b) ← ++ *((const nomodify byte*) OAM_BUFFER + (unumber)(number) $b) -Adding number conversion cast (unumber) $f in *((const nomodify byte*) OAM_BUFFER + (number) $f) ← ++ *((const nomodify byte*) OAM_BUFFER + (number) $f) -Adding number conversion cast (unumber) $f in *((const nomodify byte*) OAM_BUFFER + (number) $f) ← ++ *((const nomodify byte*) OAM_BUFFER + (unumber)(number) $f) -Adding number conversion cast (unumber) 3 in *((const nomodify byte*) OAM_BUFFER + (number) 3) ← -- *((const nomodify byte*) OAM_BUFFER + (number) 3) -Adding number conversion cast (unumber) 3 in *((const nomodify byte*) OAM_BUFFER + (number) 3) ← -- *((const nomodify byte*) OAM_BUFFER + (unumber)(number) 3) -Adding number conversion cast (unumber) 7 in *((const nomodify byte*) OAM_BUFFER + (number) 7) ← -- *((const nomodify byte*) OAM_BUFFER + (number) 7) -Adding number conversion cast (unumber) 7 in *((const nomodify byte*) OAM_BUFFER + (number) 7) ← -- *((const nomodify byte*) OAM_BUFFER + (unumber)(number) 7) -Adding number conversion cast (unumber) $b in *((const nomodify byte*) OAM_BUFFER + (number) $b) ← -- *((const nomodify byte*) OAM_BUFFER + (number) $b) -Adding number conversion cast (unumber) $b in *((const nomodify byte*) OAM_BUFFER + (number) $b) ← -- *((const nomodify byte*) OAM_BUFFER + (unumber)(number) $b) -Adding number conversion cast (unumber) $f in *((const nomodify byte*) OAM_BUFFER + (number) $f) ← -- *((const nomodify byte*) OAM_BUFFER + (number) $f) -Adding number conversion cast (unumber) $f in *((const nomodify byte*) OAM_BUFFER + (number) $f) ← -- *((const nomodify byte*) OAM_BUFFER + (unumber)(number) $f) +Adding number conversion cast (unumber) 0 in (number~) moveLuigiRight::$5 ← (number) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) moveLuigiRight::$5 in (number~) moveLuigiRight::$5 ← (unumber)(number) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) 1 in (number~) moveLuigiRight::$7 ← (number) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) moveLuigiRight::$7 in (number~) moveLuigiRight::$7 ← (unumber)(number) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) 2 in (number~) moveLuigiRight::$9 ← (number) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) moveLuigiRight::$9 in (number~) moveLuigiRight::$9 ← (unumber)(number) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) 3 in (number~) moveLuigiRight::$11 ← (number) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) moveLuigiRight::$11 in (number~) moveLuigiRight::$11 ← (unumber)(number) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) 0 in (number~) moveLuigiLeft::$5 ← (number) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) moveLuigiLeft::$5 in (number~) moveLuigiLeft::$5 ← (unumber)(number) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) 1 in (number~) moveLuigiLeft::$7 ← (number) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) moveLuigiLeft::$7 in (number~) moveLuigiLeft::$7 ← (unumber)(number) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) 2 in (number~) moveLuigiLeft::$9 ← (number) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) moveLuigiLeft::$9 in (number~) moveLuigiLeft::$9 ← (unumber)(number) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) 3 in (number~) moveLuigiLeft::$11 ← (number) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Adding number conversion cast (unumber) moveLuigiLeft::$11 in (number~) moveLuigiLeft::$11 ← (unumber)(number) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE Successful SSA optimization PassNAddNumberTypeConversions Inlining cast *((byte*~) main::disableVideoOutput1_$0) ← (unumber)(number) 0 Inlining cast *((byte*~) main::disableVideoOutput1_$1) ← (unumber)(number) 0 @@ -478,7 +473,7 @@ Successful SSA optimization Pass2InlineCast Simplifying constant pointer cast (byte*) 16128 Simplifying constant pointer cast (byte*) 16407 Simplifying constant pointer cast (byte*) 0 -Simplifying constant pointer cast (byte*) 512 +Simplifying constant pointer cast (struct ObjectAttribute*) 512 Simplifying constant pointer cast (void()*) 0 Simplifying constant pointer cast (byte*) 8194 Simplifying constant pointer cast (struct RICOH_2C02*) 8192 @@ -517,22 +512,14 @@ Simplifying constant integer cast 1 Simplifying constant integer cast 0 Simplifying constant integer cast 1 Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 Simplifying constant integer cast 3 +Simplifying constant integer cast 0 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 Simplifying constant integer cast 3 -Simplifying constant integer cast 7 -Simplifying constant integer cast 7 -Simplifying constant integer cast $b -Simplifying constant integer cast $b -Simplifying constant integer cast $f -Simplifying constant integer cast $f -Simplifying constant integer cast 3 -Simplifying constant integer cast 3 -Simplifying constant integer cast 7 -Simplifying constant integer cast 7 -Simplifying constant integer cast $b -Simplifying constant integer cast $b -Simplifying constant integer cast $f -Simplifying constant integer cast $f Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0 @@ -568,34 +555,33 @@ Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 2 Finalized unsigned number type (byte) 3 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 2 Finalized unsigned number type (byte) 3 -Finalized unsigned number type (byte) 7 -Finalized unsigned number type (byte) 7 -Finalized unsigned number type (byte) $b -Finalized unsigned number type (byte) $b -Finalized unsigned number type (byte) $f -Finalized unsigned number type (byte) $f -Finalized unsigned number type (byte) 3 -Finalized unsigned number type (byte) 3 -Finalized unsigned number type (byte) 7 -Finalized unsigned number type (byte) 7 -Finalized unsigned number type (byte) $b -Finalized unsigned number type (byte) $b -Finalized unsigned number type (byte) $f -Finalized unsigned number type (byte) $f Successful SSA optimization PassNFinalizeNumberTypeConversions Inferred type updated to byte in (unumber~) main::waitForVBlank1_$0 ← *((byte*~) main::waitForVBlank1_$2) & (byte) $80 Inferred type updated to byte in (unumber~) main::waitForVBlank2_$0 ← *((byte*~) main::waitForVBlank2_$2) & (byte) $80 Inferred type updated to byte in (unumber~) vblank::$1 ← *((byte*~) vblank::$11) & (byte) 1 Inferred type updated to byte in (unumber~) vblank::$3 ← *((byte*~) vblank::$12) & (byte) 1 +Inferred type updated to byte in (unumber~) moveLuigiRight::$5 ← (byte) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Inferred type updated to byte in (unumber~) moveLuigiRight::$7 ← (byte) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Inferred type updated to byte in (unumber~) moveLuigiRight::$9 ← (byte) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Inferred type updated to byte in (unumber~) moveLuigiRight::$11 ← (byte) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Inferred type updated to byte in (unumber~) moveLuigiLeft::$5 ← (byte) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Inferred type updated to byte in (unumber~) moveLuigiLeft::$7 ← (byte) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Inferred type updated to byte in (unumber~) moveLuigiLeft::$9 ← (byte) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Inferred type updated to byte in (unumber~) moveLuigiLeft::$11 ← (byte) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE Inversing boolean not [16] (bool~) main::waitForVBlank1_$1 ← (byte) 0 == (byte~) main::waitForVBlank1_$0 from [15] (bool~) main::waitForVBlank1_$4 ← (byte) 0 != (byte~) main::waitForVBlank1_$0 Inversing boolean not [35] (bool~) main::waitForVBlank2_$1 ← (byte) 0 == (byte~) main::waitForVBlank2_$0 from [34] (bool~) main::waitForVBlank2_$4 ← (byte) 0 != (byte~) main::waitForVBlank2_$0 Inversing boolean not [65] (bool~) vblank::$2 ← (byte) 0 == (byte~) vblank::$1 from [64] (bool~) vblank::$19 ← (byte) 0 != (byte~) vblank::$1 Inversing boolean not [71] (bool~) vblank::$4 ← (byte) 0 == (byte~) vblank::$3 from [70] (bool~) vblank::$20 ← (byte) 0 != (byte~) vblank::$3 Successful SSA optimization Pass2UnaryNotSimplification Alias initPaletteData::i#2 = initPaletteData::i#3 -Alias initSpriteData::i#2 = initSpriteData::i#3 Successful SSA optimization Pass2AliasElimination Simple Condition (bool~) main::waitForVBlank1_$1 [16] if((byte) 0==(byte~) main::waitForVBlank1_$0) goto main::waitForVBlank1_@1 Simple Condition (bool~) main::$8 [29] if((byte) 0!=(byte) main::i#1) goto main::@1 @@ -603,8 +589,8 @@ Simple Condition (bool~) main::waitForVBlank2_$1 [34] if((byte) 0==(byte~) main: Simple Condition (bool~) main::$9 [44] if((number) 0!=(number) 1) goto main::@2 Simple Condition (bool~) vblank::$2 [63] if((byte) 0==(byte~) vblank::$1) goto vblank::@1 Simple Condition (bool~) vblank::$4 [68] if((byte) 0==(byte~) vblank::$3) goto vblank::@return -Simple Condition (bool~) initPaletteData::$1 [93] if((byte) initPaletteData::i#2<(byte~) initPaletteData::$0) goto initPaletteData::@2 -Simple Condition (bool~) initSpriteData::$1 [103] if((byte) initSpriteData::i#2<(byte~) initSpriteData::$0) goto initSpriteData::@2 +Simple Condition (bool~) initPaletteData::$1 [83] if((byte) initPaletteData::i#2<(byte~) initPaletteData::$0) goto initPaletteData::@2 +Simple Condition (bool~) initSpriteData::$1 [114] if((byte) initSpriteData::i#1!=(byte~) initSpriteData::$0) goto initSpriteData::@1 Successful SSA optimization Pass2ConditionalJumpSimplification Constant right-side identified [1] (byte*~) main::disableVideoOutput1_$2 ← (byte*)(const struct RICOH_2C02*) PPU Constant right-side identified [4] (byte*~) main::disableVideoOutput1_$3 ← (byte*)(const struct RICOH_2C02*) PPU @@ -614,17 +600,26 @@ Constant right-side identified [30] (byte*~) main::waitForVBlank2_$3 ← (byte*) Constant right-side identified [37] (byte*~) main::enableVideoOutput1_$2 ← (byte*)(const struct RICOH_2C02*) PPU Constant right-side identified [40] (byte*~) main::enableVideoOutput1_$3 ← (byte*)(const struct RICOH_2C02*) PPU Constant right-side identified [46] (byte*~) vblank::$13 ← (byte*)(const struct RICOH_2C02*) PPU -Constant right-side identified [49] (byte~) vblank::$0 ← > (const nomodify byte*) OAM_BUFFER +Constant right-side identified [49] (byte~) vblank::$0 ← > (const nomodify struct ObjectAttribute*) OAM_BUFFER Constant right-side identified [50] (byte*~) vblank::$14 ← (byte*)(const struct RICOH_2A03*) APU Constant right-side identified [53] (byte*~) vblank::$15 ← (byte*)(const struct RICOH_2A03*) APU Constant right-side identified [56] (byte*~) vblank::$16 ← (byte*)(const struct RICOH_2A03*) APU Constant right-side identified [59] (byte*~) vblank::$17 ← (byte*)(const struct RICOH_2A03*) APU Constant right-side identified [64] (byte*~) vblank::$18 ← (byte*)(const struct RICOH_2A03*) APU -Constant right-side identified [83] (byte*~) initPaletteData::$5 ← (byte*)(const struct RICOH_2C02*) PPU -Constant right-side identified [86] (byte*~) initPaletteData::$6 ← (byte*)(const struct RICOH_2C02*) PPU -Constant right-side identified [91] (byte~) initPaletteData::$0 ← sizeof (const byte*) PALETTE -Constant right-side identified [94] (byte*~) initPaletteData::$7 ← (byte*)(const struct RICOH_2C02*) PPU -Constant right-side identified [101] (byte~) initSpriteData::$0 ← sizeof (const byte*) SPRITES +Constant right-side identified [73] (byte*~) initPaletteData::$5 ← (byte*)(const struct RICOH_2C02*) PPU +Constant right-side identified [76] (byte*~) initPaletteData::$6 ← (byte*)(const struct RICOH_2C02*) PPU +Constant right-side identified [81] (byte~) initPaletteData::$0 ← sizeof (const byte*) PALETTE +Constant right-side identified [84] (byte*~) initPaletteData::$7 ← (byte*)(const struct RICOH_2C02*) PPU +Constant right-side identified [89] (byte~) moveLuigiRight::$5 ← (byte) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant right-side identified [91] (byte~) moveLuigiRight::$7 ← (byte) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant right-side identified [93] (byte~) moveLuigiRight::$9 ← (byte) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant right-side identified [95] (byte~) moveLuigiRight::$11 ← (byte) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant right-side identified [98] (byte~) moveLuigiLeft::$5 ← (byte) 0 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant right-side identified [100] (byte~) moveLuigiLeft::$7 ← (byte) 1 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant right-side identified [102] (byte~) moveLuigiLeft::$9 ← (byte) 2 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant right-side identified [104] (byte~) moveLuigiLeft::$11 ← (byte) 3 * (const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant right-side identified [109] (byte*~) initSpriteData::$2 ← (byte*)(const struct ObjectAttribute*) SPRITES +Constant right-side identified [112] (byte~) initSpriteData::$0 ← sizeof (const struct ObjectAttribute*) SPRITES Successful SSA optimization Pass2ConstantRValueConsolidation Constant (const byte*) main::disableVideoOutput1_$2 = (byte*)PPU Constant (const byte*) main::disableVideoOutput1_$3 = (byte*)PPU @@ -646,7 +641,16 @@ Constant (const byte*) initPaletteData::$6 = (byte*)PPU Constant (const byte) initPaletteData::i#0 = 0 Constant (const byte) initPaletteData::$0 = sizeof PALETTE Constant (const byte*) initPaletteData::$7 = (byte*)PPU +Constant (const byte) moveLuigiRight::$5 = 0*SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant (const byte) moveLuigiRight::$7 = 1*SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant (const byte) moveLuigiRight::$9 = 2*SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant (const byte) moveLuigiRight::$11 = 3*SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant (const byte) moveLuigiLeft::$5 = 0*SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant (const byte) moveLuigiLeft::$7 = 1*SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant (const byte) moveLuigiLeft::$9 = 2*SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant (const byte) moveLuigiLeft::$11 = 3*SIZEOF_STRUCT_OBJECTATTRIBUTE Constant (const byte) initSpriteData::i#0 = 0 +Constant (const byte*) initSpriteData::$2 = (byte*)SPRITES Constant (const byte) initSpriteData::$0 = sizeof SPRITES Successful SSA optimization Pass2ConstantIdentification if() condition always true - replacing block destination [44] if((number) 0!=(number) 1) goto main::@2 @@ -664,17 +668,23 @@ Converting *(pointer+n) to pointer[n] [55] *((byte*~) vblank::$9) ← (byte) 1 Converting *(pointer+n) to pointer[n] [58] *((byte*~) vblank::$10) ← (byte) 0 -- *(vblank::$16 + OFFSET_STRUCT_RICOH_2A03_JOY1) Converting *(pointer+n) to pointer[n] [61] (byte~) vblank::$1 ← *((byte*~) vblank::$11) & (byte) 1 -- *(vblank::$17 + OFFSET_STRUCT_RICOH_2A03_JOY1) Converting *(pointer+n) to pointer[n] [66] (byte~) vblank::$3 ← *((byte*~) vblank::$12) & (byte) 1 -- *(vblank::$18 + OFFSET_STRUCT_RICOH_2A03_JOY1) -Converting *(pointer+n) to pointer[n] [85] *((byte*~) initPaletteData::$2) ← >(const nomodify byte*) PPU_PALETTE -- *(initPaletteData::$5 + OFFSET_STRUCT_RICOH_2C02_PPUADDR) -Converting *(pointer+n) to pointer[n] [88] *((byte*~) initPaletteData::$3) ← <(const nomodify byte*) PPU_PALETTE -- *(initPaletteData::$6 + OFFSET_STRUCT_RICOH_2C02_PPUADDR) -Converting *(pointer+n) to pointer[n] [96] *((byte*~) initPaletteData::$4) ← *((const byte*) PALETTE + (byte) initPaletteData::i#2) -- *(initPaletteData::$7 + OFFSET_STRUCT_RICOH_2C02_PPUDATA) +Converting *(pointer+n) to pointer[n] [75] *((byte*~) initPaletteData::$2) ← >(const nomodify byte*) PPU_PALETTE -- *(initPaletteData::$5 + OFFSET_STRUCT_RICOH_2C02_PPUADDR) +Converting *(pointer+n) to pointer[n] [78] *((byte*~) initPaletteData::$3) ← <(const nomodify byte*) PPU_PALETTE -- *(initPaletteData::$6 + OFFSET_STRUCT_RICOH_2C02_PPUADDR) +Converting *(pointer+n) to pointer[n] [86] *((byte*~) initPaletteData::$4) ← *((const byte*) PALETTE + (byte) initPaletteData::i#2) -- *(initPaletteData::$7 + OFFSET_STRUCT_RICOH_2C02_PPUDATA) Successful SSA optimization Pass2InlineDerefIdx -Simplifying constant evaluating to zero <(const nomodify byte*) PPU_PALETTE in [88] *((const byte*) initPaletteData::$6 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUADDR) ← <(const nomodify byte*) PPU_PALETTE +Simplifying constant evaluating to zero (byte) 0*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE in +Simplifying constant evaluating to zero (byte) 0*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE in +Simplifying constant evaluating to zero <(const nomodify byte*) PPU_PALETTE in [78] *((const byte*) initPaletteData::$6 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUADDR) ← <(const nomodify byte*) PPU_PALETTE Successful SSA optimization PassNSimplifyConstantZero Simplifying expression containing zero main::disableVideoOutput1_$2 in [2] (byte*~) main::disableVideoOutput1_$0 ← (const byte*) main::disableVideoOutput1_$2 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUCTRL Simplifying expression containing zero main::disableVideoOutput1_$2 in [3] *((const byte*) main::disableVideoOutput1_$2 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUCTRL) ← (byte) 0 Simplifying expression containing zero MEMORY in [19] *((const nomodify byte*) MEMORY+(byte) 0 + (byte) main::i#2) ← (byte) 0 Simplifying expression containing zero main::enableVideoOutput1_$2 in [38] (byte*~) main::enableVideoOutput1_$0 ← (const byte*) main::enableVideoOutput1_$2 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUCTRL Simplifying expression containing zero main::enableVideoOutput1_$2 in [39] *((const byte*) main::enableVideoOutput1_$2 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUCTRL) ← (byte) $80 +Simplifying expression containing zero (byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X in [90] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (const byte) moveLuigiRight::$5) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (const byte) moveLuigiRight::$5) +Simplifying expression containing zero (byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X in [90] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (const byte) moveLuigiRight::$5) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) +Simplifying expression containing zero (byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X in [99] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (const byte) moveLuigiLeft::$5) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (const byte) moveLuigiLeft::$5) +Simplifying expression containing zero (byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X in [99] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X + (const byte) moveLuigiLeft::$5) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) Successful SSA optimization PassNSimplifyExpressionWithZero Eliminating unused variable (byte*~) main::disableVideoOutput1_$0 and assignment [1] (byte*~) main::disableVideoOutput1_$0 ← (const byte*) main::disableVideoOutput1_$2 Eliminating unused variable (byte*~) main::disableVideoOutput1_$1 and assignment [3] (byte*~) main::disableVideoOutput1_$1 ← (const byte*) main::disableVideoOutput1_$3 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUMASK @@ -689,49 +699,58 @@ Eliminating unused variable (byte*~) vblank::$9 and assignment [37] (byte*~) vbl Eliminating unused variable (byte*~) vblank::$10 and assignment [39] (byte*~) vblank::$10 ← (const byte*) vblank::$16 + (const byte) OFFSET_STRUCT_RICOH_2A03_JOY1 Eliminating unused variable (byte*~) vblank::$11 and assignment [41] (byte*~) vblank::$11 ← (const byte*) vblank::$17 + (const byte) OFFSET_STRUCT_RICOH_2A03_JOY1 Eliminating unused variable (byte*~) vblank::$12 and assignment [44] (byte*~) vblank::$12 ← (const byte*) vblank::$18 + (const byte) OFFSET_STRUCT_RICOH_2A03_JOY1 -Eliminating unused variable (byte*~) initPaletteData::$2 and assignment [61] (byte*~) initPaletteData::$2 ← (const byte*) initPaletteData::$5 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUADDR -Eliminating unused variable (byte*~) initPaletteData::$3 and assignment [63] (byte*~) initPaletteData::$3 ← (const byte*) initPaletteData::$6 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUADDR -Eliminating unused variable (byte*~) initPaletteData::$4 and assignment [67] (byte*~) initPaletteData::$4 ← (const byte*) initPaletteData::$7 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUDATA +Eliminating unused variable (byte*~) initPaletteData::$2 and assignment [51] (byte*~) initPaletteData::$2 ← (const byte*) initPaletteData::$5 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUADDR +Eliminating unused variable (byte*~) initPaletteData::$3 and assignment [53] (byte*~) initPaletteData::$3 ← (const byte*) initPaletteData::$6 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUADDR +Eliminating unused variable (byte*~) initPaletteData::$4 and assignment [57] (byte*~) initPaletteData::$4 ← (const byte*) initPaletteData::$7 + (const byte) OFFSET_STRUCT_RICOH_2C02_PPUDATA +Eliminating unused constant (const byte) moveLuigiRight::$5 +Eliminating unused constant (const byte) moveLuigiLeft::$5 Eliminating unused constant (const byte) OFFSET_STRUCT_RICOH_2C02_PPUCTRL Successful SSA optimization PassNEliminateUnusedVars Removing unused block main::@return Successful SSA optimization Pass2EliminateUnusedBlocks Resolving array sizeof() sizeof (const byte*) PALETTE -Resolving array sizeof() sizeof (const byte*) SPRITES +Resolving array sizeof() sizeof (const struct ObjectAttribute*) SPRITES Successful SSA optimization PassNSizeOfSimplification Adding number conversion cast (unumber) $20 in -Adding number conversion cast (unumber) $10 in +Adding number conversion cast (unumber) 4 in Successful SSA optimization PassNAddNumberTypeConversions Simplifying constant integer cast $20 -Simplifying constant integer cast $10 +Simplifying constant integer cast 4 Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) $20 -Finalized unsigned number type (byte) $10 +Finalized unsigned number type (byte) 4 Successful SSA optimization PassNFinalizeNumberTypeConversions Inlining constant with var siblings (const byte) main::i#0 Inlining constant with var siblings (const byte) initPaletteData::i#0 Inlining constant with var siblings (const byte) initSpriteData::i#0 -Constant inlined vblank::$13 = (byte*)(const struct RICOH_2C02*) PPU Constant inlined initPaletteData::$5 = (byte*)(const struct RICOH_2C02*) PPU Constant inlined initSpriteData::i#0 = (byte) 0 -Constant inlined vblank::$14 = (byte*)(const struct RICOH_2A03*) APU Constant inlined initPaletteData::$6 = (byte*)(const struct RICOH_2C02*) PPU -Constant inlined vblank::$15 = (byte*)(const struct RICOH_2A03*) APU -Constant inlined vblank::$16 = (byte*)(const struct RICOH_2A03*) APU Constant inlined main::disableVideoOutput1_$2 = (byte*)(const struct RICOH_2C02*) PPU -Constant inlined vblank::$17 = (byte*)(const struct RICOH_2A03*) APU -Constant inlined initSpriteData::$0 = (byte) $10*(const byte) SIZEOF_BYTE -Constant inlined vblank::$18 = (byte*)(const struct RICOH_2A03*) APU Constant inlined main::disableVideoOutput1_$3 = (byte*)(const struct RICOH_2C02*) PPU Constant inlined initPaletteData::$0 = (byte) $20*(const byte) SIZEOF_BYTE +Constant inlined moveLuigiRight::$9 = (byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE Constant inlined main::enableVideoOutput1_$3 = (byte*)(const struct RICOH_2C02*) PPU Constant inlined main::enableVideoOutput1_$2 = (byte*)(const struct RICOH_2C02*) PPU Constant inlined initPaletteData::$7 = (byte*)(const struct RICOH_2C02*) PPU -Constant inlined main::waitForVBlank2_$3 = (byte*)(const struct RICOH_2C02*) PPU Constant inlined main::waitForVBlank1_$3 = (byte*)(const struct RICOH_2C02*) PPU -Constant inlined vblank::$0 = >(const nomodify byte*) OAM_BUFFER +Constant inlined vblank::$0 = >(const nomodify struct ObjectAttribute*) OAM_BUFFER Constant inlined main::i#0 = (byte) 0 Constant inlined main::disableAudioOutput1_$1 = (byte*)(const struct RICOH_2A03*) APU +Constant inlined vblank::$13 = (byte*)(const struct RICOH_2C02*) PPU +Constant inlined vblank::$14 = (byte*)(const struct RICOH_2A03*) APU +Constant inlined moveLuigiLeft::$11 = (byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant inlined vblank::$15 = (byte*)(const struct RICOH_2A03*) APU +Constant inlined initSpriteData::$2 = (byte*)(const struct ObjectAttribute*) SPRITES +Constant inlined vblank::$16 = (byte*)(const struct RICOH_2A03*) APU +Constant inlined vblank::$17 = (byte*)(const struct RICOH_2A03*) APU +Constant inlined initSpriteData::$0 = (byte) 4*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant inlined vblank::$18 = (byte*)(const struct RICOH_2A03*) APU +Constant inlined moveLuigiRight::$7 = (byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant inlined main::waitForVBlank2_$3 = (byte*)(const struct RICOH_2C02*) PPU +Constant inlined moveLuigiLeft::$7 = (byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant inlined moveLuigiRight::$11 = (byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE +Constant inlined moveLuigiLeft::$9 = (byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE Constant inlined initPaletteData::i#0 = (byte) 0 Successful SSA optimization Pass2ConstantInlining Consolidated array index constant in *((byte*)PPU+OFFSET_STRUCT_RICOH_2C02_PPUMASK) @@ -745,27 +764,24 @@ Consolidated array index constant in *((byte*)APU+OFFSET_STRUCT_RICOH_2A03_JOY1) Consolidated array index constant in *((byte*)APU+OFFSET_STRUCT_RICOH_2A03_JOY1) Consolidated array index constant in *((byte*)APU+OFFSET_STRUCT_RICOH_2A03_JOY1) Consolidated array index constant in *((byte*)APU+OFFSET_STRUCT_RICOH_2A03_JOY1) -Consolidated array index constant in *(OAM_BUFFER+3) -Consolidated array index constant in *(OAM_BUFFER+3) -Consolidated array index constant in *(OAM_BUFFER+7) -Consolidated array index constant in *(OAM_BUFFER+7) -Consolidated array index constant in *(OAM_BUFFER+$b) -Consolidated array index constant in *(OAM_BUFFER+$b) -Consolidated array index constant in *(OAM_BUFFER+$f) -Consolidated array index constant in *(OAM_BUFFER+$f) -Consolidated array index constant in *(OAM_BUFFER+3) -Consolidated array index constant in *(OAM_BUFFER+3) -Consolidated array index constant in *(OAM_BUFFER+7) -Consolidated array index constant in *(OAM_BUFFER+7) -Consolidated array index constant in *(OAM_BUFFER+$b) -Consolidated array index constant in *(OAM_BUFFER+$b) -Consolidated array index constant in *(OAM_BUFFER+$f) -Consolidated array index constant in *(OAM_BUFFER+$f) Consolidated array index constant in *((byte*)PPU+OFFSET_STRUCT_RICOH_2C02_PPUADDR) Consolidated array index constant in *((byte*)PPU+OFFSET_STRUCT_RICOH_2C02_PPUADDR) Consolidated array index constant in *((byte*)PPU+OFFSET_STRUCT_RICOH_2C02_PPUDATA) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE) +Consolidated array index constant in *((byte*)OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE) Successful SSA optimization Pass2ConstantAdditionElimination Added new block during phi lifting main::@7(between main::@1 and main::@1) +Added new block during phi lifting initSpriteData::@2(between initSpriteData::@1 and initSpriteData::@1) Adding NOP phi() at start of @begin Adding NOP phi() at start of @1 Adding NOP phi() at start of @2 @@ -789,13 +805,14 @@ Calls in [vblank] to moveLuigiRight:61 moveLuigiLeft:66 Created 3 initial phi equivalence classes Coalesced [37] main::i#3 ← main::i#1 -Coalesced [44] initSpriteData::i#4 ← initSpriteData::i#1 +Coalesced [44] initSpriteData::i#3 ← initSpriteData::i#1 Coalesced [53] initPaletteData::i#4 ← initPaletteData::i#1 Coalesced down to 3 phi equivalence classes Culled Empty Block (label) @2 Culled Empty Block (label) main::@3 Culled Empty Block (label) main::@6 Culled Empty Block (label) main::@7 +Culled Empty Block (label) initSpriteData::@2 Culled Empty Block (label) vblank::@4 Culled Empty Block (label) vblank::@5 Renumbering block main::@4 to main::@3 @@ -885,17 +902,15 @@ main::@2: scope:[main] from main::@2 main::enableVideoOutput1 initSpriteData: scope:[initSpriteData] from main::@4 [34] phi() to:initSpriteData::@1 -initSpriteData::@1: scope:[initSpriteData] from initSpriteData initSpriteData::@2 - [35] (byte) initSpriteData::i#2 ← phi( initSpriteData/(byte) 0 initSpriteData::@2/(byte) initSpriteData::i#1 ) - [36] if((byte) initSpriteData::i#2<(byte) $10*(const byte) SIZEOF_BYTE) goto initSpriteData::@2 +initSpriteData::@1: scope:[initSpriteData] from initSpriteData initSpriteData::@1 + [35] (byte) initSpriteData::i#2 ← phi( initSpriteData/(byte) 0 initSpriteData::@1/(byte) initSpriteData::i#1 ) + [36] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((byte*)(const struct ObjectAttribute*) SPRITES + (byte) initSpriteData::i#2) + [37] (byte) initSpriteData::i#1 ← ++ (byte) initSpriteData::i#2 + [38] if((byte) initSpriteData::i#1!=(byte) 4*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) goto initSpriteData::@1 to:initSpriteData::@return initSpriteData::@return: scope:[initSpriteData] from initSpriteData::@1 - [37] return + [39] return to:@return -initSpriteData::@2: scope:[initSpriteData] from initSpriteData::@1 - [38] *((const nomodify byte*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((const byte*) SPRITES + (byte) initSpriteData::i#2) - [39] (byte) initSpriteData::i#1 ← ++ (byte) initSpriteData::i#2 - to:initSpriteData::@1 (void()) initPaletteData() initPaletteData: scope:[initPaletteData] from main::@3 @@ -918,7 +933,7 @@ initPaletteData::@2: scope:[initPaletteData] from initPaletteData::@1 interrupt(HARDWARE_STACK)(void()) vblank() vblank: scope:[vblank] from [48] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_OAMADDR) ← (byte) 0 - [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify byte*) OAM_BUFFER + [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify struct ObjectAttribute*) OAM_BUFFER [50] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) ← (byte) 1 [51] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) ← (byte) 0 [52] (byte~) vblank::$1 ← *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) & (byte) 1 @@ -942,10 +957,10 @@ vblank::@return: scope:[vblank] from vblank::@1 vblank::@3 (void()) moveLuigiLeft() moveLuigiLeft: scope:[moveLuigiLeft] from vblank::@3 - [61] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 3) - [62] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 7) - [63] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $b) - [64] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $f) + [61] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) + [62] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) + [63] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) + [64] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) to:moveLuigiLeft::@return moveLuigiLeft::@return: scope:[moveLuigiLeft] from moveLuigiLeft [65] return @@ -953,10 +968,10 @@ moveLuigiLeft::@return: scope:[moveLuigiLeft] from moveLuigiLeft (void()) moveLuigiRight() moveLuigiRight: scope:[moveLuigiRight] from vblank::@2 - [66] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 3) - [67] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 7) - [68] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $b) - [69] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $f) + [66] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) + [67] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) + [68] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) + [69] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) to:moveLuigiRight::@return moveLuigiRight::@return: scope:[moveLuigiRight] from moveLuigiRight [70] return @@ -964,6 +979,10 @@ moveLuigiRight::@return: scope:[moveLuigiRight] from moveLuigiRight VARIABLE REGISTER WEIGHTS +(byte) ObjectAttribute::attributes +(byte) ObjectAttribute::tile +(byte) ObjectAttribute::x +(byte) ObjectAttribute::y (byte) RICOH_2A03::DMC_FREQ (byte) RICOH_2A03::DMC_LEN (byte) RICOH_2A03::DMC_RAW @@ -1002,8 +1021,8 @@ VARIABLE REGISTER WEIGHTS (byte) initPaletteData::i#2 1334.6666666666667 (void()) initSpriteData() (byte) initSpriteData::i -(byte) initSpriteData::i#1 2002.0 -(byte) initSpriteData::i#2 1668.3333333333335 +(byte) initSpriteData::i#1 1501.5 +(byte) initSpriteData::i#2 2002.0 (void()) main() (byte) main::i (byte) main::i#1 151.5 @@ -1075,6 +1094,7 @@ Target platform is nes / MOS6502 .segment Code // Global Constants & labels + .const SIZEOF_STRUCT_OBJECTATTRIBUTE = 4 .const OFFSET_STRUCT_RICOH_2A03_DMC_FREQ = $10 .const OFFSET_STRUCT_RICOH_2C02_PPUMASK = 1 .const OFFSET_STRUCT_RICOH_2C02_PPUSTATUS = 2 @@ -1083,6 +1103,7 @@ Target platform is nes / MOS6502 .const OFFSET_STRUCT_RICOH_2A03_JOY1 = $16 .const OFFSET_STRUCT_RICOH_2C02_PPUADDR = 6 .const OFFSET_STRUCT_RICOH_2C02_PPUDATA = 7 + .const OFFSET_STRUCT_OBJECTATTRIBUTE_X = 3 .const SIZEOF_BYTE = 1 // $3000-$3EFF $0F00 Mirrors of $2000-$2EFF // $3F00-$3F1F $0020 Palette RAM indexes @@ -1286,29 +1307,27 @@ initSpriteData: { lda #0 sta.z i jmp __b1 + // [35] phi from initSpriteData::@1 to initSpriteData::@1 [phi:initSpriteData::@1->initSpriteData::@1] + __b1_from___b1: + // [35] phi (byte) initSpriteData::i#2 = (byte) initSpriteData::i#1 [phi:initSpriteData::@1->initSpriteData::@1#0] -- register_copy + jmp __b1 // initSpriteData::@1 __b1: - // [36] if((byte) initSpriteData::i#2<(byte) $10*(const byte) SIZEOF_BYTE) goto initSpriteData::@2 -- vbuz1_lt_vbuc1_then_la1 - lda.z i - cmp #$10*SIZEOF_BYTE - bcc __b2 - jmp __breturn - // initSpriteData::@return - __breturn: - // [37] return - rts - // initSpriteData::@2 - __b2: - // [38] *((const nomodify byte*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((const byte*) SPRITES + (byte) initSpriteData::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + // [36] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((byte*)(const struct ObjectAttribute*) SPRITES + (byte) initSpriteData::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 ldy.z i lda SPRITES,y sta OAM_BUFFER,y - // [39] (byte) initSpriteData::i#1 ← ++ (byte) initSpriteData::i#2 -- vbuz1=_inc_vbuz1 + // [37] (byte) initSpriteData::i#1 ← ++ (byte) initSpriteData::i#2 -- vbuz1=_inc_vbuz1 inc.z i - // [35] phi from initSpriteData::@2 to initSpriteData::@1 [phi:initSpriteData::@2->initSpriteData::@1] - __b1_from___b2: - // [35] phi (byte) initSpriteData::i#2 = (byte) initSpriteData::i#1 [phi:initSpriteData::@2->initSpriteData::@1#0] -- register_copy - jmp __b1 + // [38] if((byte) initSpriteData::i#1!=(byte) 4*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) goto initSpriteData::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #4*SIZEOF_STRUCT_OBJECTATTRIBUTE + cmp.z i + bne __b1_from___b1 + jmp __breturn + // initSpriteData::@return + __breturn: + // [39] return + rts } // initPaletteData // Copy palette values to PPU @@ -1372,7 +1391,7 @@ vblank: { // Set OAM start address to sprite#0 lda #0 sta PPU+OFFSET_STRUCT_RICOH_2C02_OAMADDR - // [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify byte*) OAM_BUFFER -- _deref_pbuc1=vbuc2 + // [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify struct ObjectAttribute*) OAM_BUFFER -- _deref_pbuc1=vbuc2 // Set the high byte (02) of the RAM address and start the DMA transfer to OAM memory lda #>OAM_BUFFER sta APU+OFFSET_STRUCT_RICOH_2A03_OAMDMA @@ -1430,14 +1449,14 @@ vblank: { // moveLuigiLeft // move the Luigi sprites left moveLuigiLeft: { - // [61] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 3) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+3 - // [62] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 7) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+7 - // [63] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $b) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+$b - // [64] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $f) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+$f + // [61] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X + // [62] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE + // [63] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE + // [64] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE jmp __breturn // moveLuigiLeft::@return __breturn: @@ -1447,14 +1466,14 @@ moveLuigiLeft: { // moveLuigiRight // move the Luigi sprites right moveLuigiRight: { - // [66] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 3) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+3 - // [67] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 7) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+7 - // [68] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $b) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+$b - // [69] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $f) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+$f + // [66] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X + // [67] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE + // [68] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE + // [69] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE jmp __breturn // moveLuigiRight::@return __breturn: @@ -1499,7 +1518,7 @@ Statement [21] *((const nomodify byte*) MEMORY+(word) $700 + (byte) main::i#2) Statement [25] (byte~) main::waitForVBlank2_$0 ← *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_PPUSTATUS) & (byte) $80 [ main::waitForVBlank2_$0 ] ( [ main::waitForVBlank2_$0 ] { } main:2 [ main::waitForVBlank2_$0 ] { } ) always clobbers reg byte a Statement [31] *((byte*)(const struct RICOH_2C02*) PPU) ← (byte) $80 [ ] ( [ ] { } main:2 [ ] { } ) always clobbers reg byte a Statement [32] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_PPUMASK) ← (byte) $10 [ ] ( [ ] { } main:2 [ ] { } ) always clobbers reg byte a -Statement [38] *((const nomodify byte*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((const byte*) SPRITES + (byte) initSpriteData::i#2) [ initSpriteData::i#2 ] ( initSpriteData:30 [ initSpriteData::i#2 ] { } main:2::initSpriteData:30 [ initSpriteData::i#2 ] { } ) always clobbers reg byte a +Statement [36] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((byte*)(const struct ObjectAttribute*) SPRITES + (byte) initSpriteData::i#2) [ initSpriteData::i#2 ] ( initSpriteData:30 [ initSpriteData::i#2 ] { } main:2::initSpriteData:30 [ initSpriteData::i#2 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:3 [ initSpriteData::i#2 initSpriteData::i#1 ] Statement asm { ldaPPU_PPUSTATUS } always clobbers reg byte a Statement [41] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_PPUADDR) ← >(const nomodify byte*) PPU_PALETTE [ ] ( initPaletteData:28 [ ] { } main:2::initPaletteData:28 [ ] { } ) always clobbers reg byte a @@ -1507,7 +1526,7 @@ Statement [42] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUC Statement [46] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_PPUDATA) ← *((const byte*) PALETTE + (byte) initPaletteData::i#2) [ initPaletteData::i#2 ] ( initPaletteData:28 [ initPaletteData::i#2 ] { } main:2::initPaletteData:28 [ initPaletteData::i#2 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:4 [ initPaletteData::i#2 initPaletteData::i#1 ] Statement [48] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_OAMADDR) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a -Statement [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify byte*) OAM_BUFFER [ ] ( [ ] { } ) always clobbers reg byte a +Statement [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify struct ObjectAttribute*) OAM_BUFFER [ ] ( [ ] { } ) always clobbers reg byte a Statement [50] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) ← (byte) 1 [ ] ( [ ] { } ) always clobbers reg byte a Statement [51] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a Statement [52] (byte~) vblank::$1 ← *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) & (byte) 1 [ vblank::$1 ] ( [ vblank::$1 ] { } ) always clobbers reg byte a @@ -1531,13 +1550,13 @@ Statement [21] *((const nomodify byte*) MEMORY+(word) $700 + (byte) main::i#2) Statement [25] (byte~) main::waitForVBlank2_$0 ← *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_PPUSTATUS) & (byte) $80 [ main::waitForVBlank2_$0 ] ( [ main::waitForVBlank2_$0 ] { } main:2 [ main::waitForVBlank2_$0 ] { } ) always clobbers reg byte a Statement [31] *((byte*)(const struct RICOH_2C02*) PPU) ← (byte) $80 [ ] ( [ ] { } main:2 [ ] { } ) always clobbers reg byte a Statement [32] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_PPUMASK) ← (byte) $10 [ ] ( [ ] { } main:2 [ ] { } ) always clobbers reg byte a -Statement [38] *((const nomodify byte*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((const byte*) SPRITES + (byte) initSpriteData::i#2) [ initSpriteData::i#2 ] ( initSpriteData:30 [ initSpriteData::i#2 ] { } main:2::initSpriteData:30 [ initSpriteData::i#2 ] { } ) always clobbers reg byte a +Statement [36] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((byte*)(const struct ObjectAttribute*) SPRITES + (byte) initSpriteData::i#2) [ initSpriteData::i#2 ] ( initSpriteData:30 [ initSpriteData::i#2 ] { } main:2::initSpriteData:30 [ initSpriteData::i#2 ] { } ) always clobbers reg byte a Statement asm { ldaPPU_PPUSTATUS } always clobbers reg byte a Statement [41] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_PPUADDR) ← >(const nomodify byte*) PPU_PALETTE [ ] ( initPaletteData:28 [ ] { } main:2::initPaletteData:28 [ ] { } ) always clobbers reg byte a Statement [42] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_PPUADDR) ← (byte) 0 [ ] ( initPaletteData:28 [ ] { } main:2::initPaletteData:28 [ ] { } ) always clobbers reg byte a Statement [46] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_PPUDATA) ← *((const byte*) PALETTE + (byte) initPaletteData::i#2) [ initPaletteData::i#2 ] ( initPaletteData:28 [ initPaletteData::i#2 ] { } main:2::initPaletteData:28 [ initPaletteData::i#2 ] { } ) always clobbers reg byte a Statement [48] *((byte*)(const struct RICOH_2C02*) PPU+(const byte) OFFSET_STRUCT_RICOH_2C02_OAMADDR) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a -Statement [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify byte*) OAM_BUFFER [ ] ( [ ] { } ) always clobbers reg byte a +Statement [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify struct ObjectAttribute*) OAM_BUFFER [ ] ( [ ] { } ) always clobbers reg byte a Statement [50] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) ← (byte) 1 [ ] ( [ ] { } ) always clobbers reg byte a Statement [51] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a Statement [52] (byte~) vblank::$1 ← *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_JOY1) & (byte) 1 [ vblank::$1 ] ( [ vblank::$1 ] { } ) always clobbers reg byte a @@ -1552,12 +1571,13 @@ Potential registers zp[1]:7 [ vblank::$1 ] : zp[1]:7 , reg byte a , reg byte x , Potential registers zp[1]:8 [ vblank::$3 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y , REGISTER UPLIFT SCOPES -Uplift Scope [initSpriteData] 3,670.33: zp[1]:3 [ initSpriteData::i#2 initSpriteData::i#1 ] +Uplift Scope [initSpriteData] 3,503.5: zp[1]:3 [ initSpriteData::i#2 initSpriteData::i#1 ] Uplift Scope [initPaletteData] 3,336.67: zp[1]:4 [ initPaletteData::i#2 initPaletteData::i#1 ] Uplift Scope [main] 263.72: zp[1]:2 [ main::i#2 main::i#1 ] 202: zp[1]:5 [ main::waitForVBlank1_$0 ] 202: zp[1]:6 [ main::waitForVBlank2_$0 ] Uplift Scope [vblank] 4: zp[1]:7 [ vblank::$1 ] 4: zp[1]:8 [ vblank::$3 ] Uplift Scope [RICOH_2C02] Uplift Scope [RICOH_2A03] +Uplift Scope [ObjectAttribute] Uplift Scope [moveLuigiRight] Uplift Scope [moveLuigiLeft] Uplift Scope [] @@ -1568,6 +1588,7 @@ Uplifting [main] best 1985 combination reg byte x [ main::i#2 main::i#1 ] reg by Uplifting [vblank] best 1973 combination reg byte a [ vblank::$1 ] reg byte a [ vblank::$3 ] Uplifting [RICOH_2C02] best 1973 combination Uplifting [RICOH_2A03] best 1973 combination +Uplifting [ObjectAttribute] best 1973 combination Uplifting [moveLuigiRight] best 1973 combination Uplifting [moveLuigiLeft] best 1973 combination Uplifting [] best 1973 combination @@ -1606,6 +1627,7 @@ ASSEMBLER BEFORE OPTIMIZATION .segment Code // Global Constants & labels + .const SIZEOF_STRUCT_OBJECTATTRIBUTE = 4 .const OFFSET_STRUCT_RICOH_2A03_DMC_FREQ = $10 .const OFFSET_STRUCT_RICOH_2C02_PPUMASK = 1 .const OFFSET_STRUCT_RICOH_2C02_PPUSTATUS = 2 @@ -1614,6 +1636,7 @@ ASSEMBLER BEFORE OPTIMIZATION .const OFFSET_STRUCT_RICOH_2A03_JOY1 = $16 .const OFFSET_STRUCT_RICOH_2C02_PPUADDR = 6 .const OFFSET_STRUCT_RICOH_2C02_PPUDATA = 7 + .const OFFSET_STRUCT_OBJECTATTRIBUTE_X = 3 .const SIZEOF_BYTE = 1 // $3000-$3EFF $0F00 Mirrors of $2000-$2EFF // $3F00-$3F1F $0020 Palette RAM indexes @@ -1797,27 +1820,25 @@ initSpriteData: { // [35] phi (byte) initSpriteData::i#2 = (byte) 0 [phi:initSpriteData->initSpriteData::@1#0] -- vbuxx=vbuc1 ldx #0 jmp __b1 + // [35] phi from initSpriteData::@1 to initSpriteData::@1 [phi:initSpriteData::@1->initSpriteData::@1] + __b1_from___b1: + // [35] phi (byte) initSpriteData::i#2 = (byte) initSpriteData::i#1 [phi:initSpriteData::@1->initSpriteData::@1#0] -- register_copy + jmp __b1 // initSpriteData::@1 __b1: - // [36] if((byte) initSpriteData::i#2<(byte) $10*(const byte) SIZEOF_BYTE) goto initSpriteData::@2 -- vbuxx_lt_vbuc1_then_la1 - cpx #$10*SIZEOF_BYTE - bcc __b2 + // [36] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((byte*)(const struct ObjectAttribute*) SPRITES + (byte) initSpriteData::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda SPRITES,x + sta OAM_BUFFER,x + // [37] (byte) initSpriteData::i#1 ← ++ (byte) initSpriteData::i#2 -- vbuxx=_inc_vbuxx + inx + // [38] if((byte) initSpriteData::i#1!=(byte) 4*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) goto initSpriteData::@1 -- vbuxx_neq_vbuc1_then_la1 + cpx #4*SIZEOF_STRUCT_OBJECTATTRIBUTE + bne __b1_from___b1 jmp __breturn // initSpriteData::@return __breturn: - // [37] return + // [39] return rts - // initSpriteData::@2 - __b2: - // [38] *((const nomodify byte*) OAM_BUFFER + (byte) initSpriteData::i#2) ← *((const byte*) SPRITES + (byte) initSpriteData::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx - lda SPRITES,x - sta OAM_BUFFER,x - // [39] (byte) initSpriteData::i#1 ← ++ (byte) initSpriteData::i#2 -- vbuxx=_inc_vbuxx - inx - // [35] phi from initSpriteData::@2 to initSpriteData::@1 [phi:initSpriteData::@2->initSpriteData::@1] - __b1_from___b2: - // [35] phi (byte) initSpriteData::i#2 = (byte) initSpriteData::i#1 [phi:initSpriteData::@2->initSpriteData::@1#0] -- register_copy - jmp __b1 } // initPaletteData // Copy palette values to PPU @@ -1875,7 +1896,7 @@ vblank: { // Set OAM start address to sprite#0 lda #0 sta PPU+OFFSET_STRUCT_RICOH_2C02_OAMADDR - // [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify byte*) OAM_BUFFER -- _deref_pbuc1=vbuc2 + // [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify struct ObjectAttribute*) OAM_BUFFER -- _deref_pbuc1=vbuc2 // Set the high byte (02) of the RAM address and start the DMA transfer to OAM memory lda #>OAM_BUFFER sta APU+OFFSET_STRUCT_RICOH_2A03_OAMDMA @@ -1929,14 +1950,14 @@ vblank: { // moveLuigiLeft // move the Luigi sprites left moveLuigiLeft: { - // [61] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 3) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+3 - // [62] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 7) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+7 - // [63] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $b) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+$b - // [64] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $f) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+$f + // [61] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X + // [62] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE + // [63] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE + // [64] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE jmp __breturn // moveLuigiLeft::@return __breturn: @@ -1946,14 +1967,14 @@ moveLuigiLeft: { // moveLuigiRight // move the Luigi sprites right moveLuigiRight: { - // [66] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 3) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+3 - // [67] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 7) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+7 - // [68] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $b) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+$b - // [69] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $f) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+$f + // [66] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X + // [67] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE + // [68] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE + // [69] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE jmp __breturn // moveLuigiRight::@return __breturn: @@ -2017,6 +2038,7 @@ Succesful ASM optimization Pass5UnnecesaryLoadElimination Replacing label waitForVBlank1___b1 with waitForVBlank1 Replacing label __b1_from___b1 with __b1 Replacing label waitForVBlank2___b1 with waitForVBlank2 +Replacing label __b1_from___b1 with __b1 Removing instruction __b1_from___bbegin: Removing instruction __b1: Removing instruction __bend_from___b1: @@ -2029,6 +2051,7 @@ Removing instruction __b3_from_waitForVBlank2___b1: Removing instruction __b4_from___b3: Removing instruction initSpriteData_from___b4: Removing instruction __b2_from_enableVideoOutput1: +Removing instruction __b1_from___b1: Removing instruction __b2_from_vblank: Removing instruction __b3_from___b1: Succesful ASM optimization Pass5RedundantLabelElimination @@ -2044,7 +2067,6 @@ Removing instruction enableVideoOutput1: Removing instruction __b2: Removing instruction __b1_from_initSpriteData: Removing instruction __breturn: -Removing instruction __b1_from___b2: Removing instruction __b1_from_initPaletteData: Removing instruction __breturn: Removing instruction __b1_from___b2: @@ -2058,6 +2080,7 @@ Succesful ASM optimization Pass5SkipBegin Relabelling long label __b2_from___b2 to __b2 Succesful ASM optimization Pass5RelabelLongLabels Removing instruction jmp __b1 +Removing instruction jmp __b1 Succesful ASM optimization Pass5NextJumpElimination Replacing instruction ldx #0 with TAX @@ -2072,7 +2095,8 @@ FINAL SYMBOL TABLE .segmentout [ segments="ProgramRom" ] .segmentout [ segments="CharacterRom" ] }} -(const nomodify byte*) OAM_BUFFER = (byte*) 512 +(const nomodify struct ObjectAttribute*) OAM_BUFFER = (struct ObjectAttribute*) 512 +(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X = (byte) 3 (const byte) OFFSET_STRUCT_RICOH_2A03_DMC_FREQ = (byte) $10 (const byte) OFFSET_STRUCT_RICOH_2A03_JOY1 = (byte) $16 (const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA = (byte) $14 @@ -2081,6 +2105,10 @@ FINAL SYMBOL TABLE (const byte) OFFSET_STRUCT_RICOH_2C02_PPUDATA = (byte) 7 (const byte) OFFSET_STRUCT_RICOH_2C02_PPUMASK = (byte) 1 (const byte) OFFSET_STRUCT_RICOH_2C02_PPUSTATUS = (byte) 2 +(byte) ObjectAttribute::attributes +(byte) ObjectAttribute::tile +(byte) ObjectAttribute::x +(byte) ObjectAttribute::y (const byte*) PALETTE[(number) $20] = { (byte) $f, (byte) $31, (byte) $32, (byte) $33, (byte) $f, (byte) $35, (byte) $36, (byte) $37, (byte) $f, (byte) $39, (byte) $3a, (byte) $3b, (byte) $f, (byte) $3d, (byte) $3e, (byte) $f, (byte) $f, (byte) $1c, (byte) $15, (byte) $14, (byte) $f, (byte) 2, (byte) $38, (byte) $3c, (byte) $f, (byte) $30, (byte) $37, (byte) $1a, (byte) $f, (byte) $f, (byte) $f, (byte) $f } (const struct RICOH_2C02*) PPU = (struct RICOH_2C02*) 8192 (const nomodify byte*) PPU_PALETTE = (byte*) 16128 @@ -2118,7 +2146,8 @@ FINAL SYMBOL TABLE (byte) RICOH_2C02::PPUSCROLL (volatile byte) RICOH_2C02::PPUSTATUS loadstore (const byte) SIZEOF_BYTE = (byte) 1 -(const byte*) SPRITES[] = { (byte) $80, (byte) $36, (byte) 2, (byte) $80, (byte) $80, (byte) $37, (byte) 2, (byte) $88, (byte) $88, (byte) $38, (byte) 2, (byte) $80, (byte) $88, (byte) $39, (byte) 2, (byte) $88 } +(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE = (byte) 4 +(const struct ObjectAttribute*) SPRITES[] = { { y: (byte) $80, tile: (byte) $36, attributes: (byte) 2, x: (byte) $80 }, { y: (byte) $80, tile: (byte) $37, attributes: (byte) 2, x: (byte) $88 }, { y: (byte) $88, tile: (byte) $38, attributes: (byte) 2, x: (byte) $80 }, { y: (byte) $88, tile: (byte) $39, attributes: (byte) 2, x: (byte) $88 } } (const byte*) TILES[] = kickasm {{ .import binary "smb1_chr.bin" }} (const to_nomodify void()**) VECTORS[] = { &interrupt(HARDWARE_STACK)(void()) vblank(), &(void()) main(), (void()*) 0 } @@ -2131,11 +2160,10 @@ FINAL SYMBOL TABLE (byte) initPaletteData::i#2 reg byte x 1334.6666666666667 (void()) initSpriteData() (label) initSpriteData::@1 -(label) initSpriteData::@2 (label) initSpriteData::@return (byte) initSpriteData::i -(byte) initSpriteData::i#1 reg byte x 2002.0 -(byte) initSpriteData::i#2 reg byte x 1668.3333333333335 +(byte) initSpriteData::i#1 reg byte x 1501.5 +(byte) initSpriteData::i#2 reg byte x 2002.0 (void()) main() (label) main::@1 (label) main::@2 @@ -2176,7 +2204,7 @@ reg byte a [ vblank::$3 ] FINAL ASSEMBLER -Score: 1505 +Score: 1475 // File Comments // A minimal NES demo @@ -2211,6 +2239,7 @@ Score: 1505 .segment Code // Global Constants & labels + .const SIZEOF_STRUCT_OBJECTATTRIBUTE = 4 .const OFFSET_STRUCT_RICOH_2A03_DMC_FREQ = $10 .const OFFSET_STRUCT_RICOH_2C02_PPUMASK = 1 .const OFFSET_STRUCT_RICOH_2C02_PPUSTATUS = 2 @@ -2219,6 +2248,7 @@ Score: 1505 .const OFFSET_STRUCT_RICOH_2A03_JOY1 = $16 .const OFFSET_STRUCT_RICOH_2C02_PPUADDR = 6 .const OFFSET_STRUCT_RICOH_2C02_PPUDATA = 7 + .const OFFSET_STRUCT_OBJECTATTRIBUTE_X = 3 .const SIZEOF_BYTE = 1 // $3000-$3EFF $0F00 Mirrors of $2000-$2EFF // $3F00-$3F1F $0020 Palette RAM indexes @@ -2376,28 +2406,24 @@ initSpriteData: { // [35] phi from initSpriteData to initSpriteData::@1 [phi:initSpriteData->initSpriteData::@1] // [35] phi (byte) initSpriteData::i#2 = (byte) 0 [phi:initSpriteData->initSpriteData::@1#0] -- vbuxx=vbuc1 ldx #0 + // [35] phi from initSpriteData::@1 to initSpriteData::@1 [phi:initSpriteData::@1->initSpriteData::@1] + // [35] phi (byte) initSpriteData::i#2 = (byte) initSpriteData::i#1 [phi:initSpriteData::@1->initSpriteData::@1#0] -- register_copy // initSpriteData::@1 __b1: - // for(char i=0;iinitSpriteData::@1] - // [35] phi (byte) initSpriteData::i#2 = (byte) initSpriteData::i#1 [phi:initSpriteData::@2->initSpriteData::@1#0] -- register_copy - jmp __b1 + // [38] if((byte) initSpriteData::i#1!=(byte) 4*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) goto initSpriteData::@1 -- vbuxx_neq_vbuc1_then_la1 + cpx #4*SIZEOF_STRUCT_OBJECTATTRIBUTE + bne __b1 + // initSpriteData::@return + // } + // [39] return + rts } // initPaletteData // Copy palette values to PPU @@ -2459,7 +2485,7 @@ vblank: { lda #0 sta PPU+OFFSET_STRUCT_RICOH_2C02_OAMADDR // APU->OAMDMA = >OAM_BUFFER - // [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify byte*) OAM_BUFFER -- _deref_pbuc1=vbuc2 + // [49] *((byte*)(const struct RICOH_2A03*) APU+(const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA) ← >(const nomodify struct ObjectAttribute*) OAM_BUFFER -- _deref_pbuc1=vbuc2 // Set the high byte (02) of the RAM address and start the DMA transfer to OAM memory lda #>OAM_BUFFER sta APU+OFFSET_STRUCT_RICOH_2A03_OAMDMA @@ -2514,18 +2540,18 @@ vblank: { // moveLuigiLeft // move the Luigi sprites left moveLuigiLeft: { - // OAM_BUFFER[0x03]--; - // [61] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 3) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+3 - // OAM_BUFFER[0x07]--; - // [62] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) 7) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+7 - // OAM_BUFFER[0x0b]--; - // [63] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $b) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+$b - // OAM_BUFFER[0x0f]--; - // [64] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← -- *((const nomodify byte*) OAM_BUFFER+(byte) $f) -- _deref_pbuc1=_dec__deref_pbuc1 - dec OAM_BUFFER+$f + // OAM_BUFFER[0].x--; + // [61] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X + // OAM_BUFFER[1].x--; + // [62] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE + // OAM_BUFFER[2].x--; + // [63] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE + // OAM_BUFFER[3].x--; + // [64] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← -- *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_dec__deref_pbuc1 + dec OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE // moveLuigiLeft::@return // } // [65] return @@ -2534,18 +2560,18 @@ moveLuigiLeft: { // moveLuigiRight // move the Luigi sprites right moveLuigiRight: { - // OAM_BUFFER[0x03]++; - // [66] *((const nomodify byte*) OAM_BUFFER+(byte) 3) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 3) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+3 - // OAM_BUFFER[0x07]++; - // [67] *((const nomodify byte*) OAM_BUFFER+(byte) 7) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) 7) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+7 - // OAM_BUFFER[0x0b]++; - // [68] *((const nomodify byte*) OAM_BUFFER+(byte) $b) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $b) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+$b - // OAM_BUFFER[0x0f]++; - // [69] *((const nomodify byte*) OAM_BUFFER+(byte) $f) ← ++ *((const nomodify byte*) OAM_BUFFER+(byte) $f) -- _deref_pbuc1=_inc__deref_pbuc1 - inc OAM_BUFFER+$f + // OAM_BUFFER[0].x++; + // [66] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X + // OAM_BUFFER[1].x++; + // [67] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 1*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+1*SIZEOF_STRUCT_OBJECTATTRIBUTE + // OAM_BUFFER[2].x++; + // [68] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 2*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+2*SIZEOF_STRUCT_OBJECTATTRIBUTE + // OAM_BUFFER[3].x++; + // [69] *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) ← ++ *((byte*)(const nomodify struct ObjectAttribute*) OAM_BUFFER+(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X+(byte) 3*(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE) -- _deref_pbuc1=_inc__deref_pbuc1 + inc OAM_BUFFER+OFFSET_STRUCT_OBJECTATTRIBUTE_X+3*SIZEOF_STRUCT_OBJECTATTRIBUTE // moveLuigiRight::@return // } // [70] return diff --git a/src/test/ref/examples/nes/nes-demo.sym b/src/test/ref/examples/nes/nes-demo.sym index c257dd836..b253c1d2b 100644 --- a/src/test/ref/examples/nes/nes-demo.sym +++ b/src/test/ref/examples/nes/nes-demo.sym @@ -8,7 +8,8 @@ .segmentout [ segments="ProgramRom" ] .segmentout [ segments="CharacterRom" ] }} -(const nomodify byte*) OAM_BUFFER = (byte*) 512 +(const nomodify struct ObjectAttribute*) OAM_BUFFER = (struct ObjectAttribute*) 512 +(const byte) OFFSET_STRUCT_OBJECTATTRIBUTE_X = (byte) 3 (const byte) OFFSET_STRUCT_RICOH_2A03_DMC_FREQ = (byte) $10 (const byte) OFFSET_STRUCT_RICOH_2A03_JOY1 = (byte) $16 (const byte) OFFSET_STRUCT_RICOH_2A03_OAMDMA = (byte) $14 @@ -17,6 +18,10 @@ (const byte) OFFSET_STRUCT_RICOH_2C02_PPUDATA = (byte) 7 (const byte) OFFSET_STRUCT_RICOH_2C02_PPUMASK = (byte) 1 (const byte) OFFSET_STRUCT_RICOH_2C02_PPUSTATUS = (byte) 2 +(byte) ObjectAttribute::attributes +(byte) ObjectAttribute::tile +(byte) ObjectAttribute::x +(byte) ObjectAttribute::y (const byte*) PALETTE[(number) $20] = { (byte) $f, (byte) $31, (byte) $32, (byte) $33, (byte) $f, (byte) $35, (byte) $36, (byte) $37, (byte) $f, (byte) $39, (byte) $3a, (byte) $3b, (byte) $f, (byte) $3d, (byte) $3e, (byte) $f, (byte) $f, (byte) $1c, (byte) $15, (byte) $14, (byte) $f, (byte) 2, (byte) $38, (byte) $3c, (byte) $f, (byte) $30, (byte) $37, (byte) $1a, (byte) $f, (byte) $f, (byte) $f, (byte) $f } (const struct RICOH_2C02*) PPU = (struct RICOH_2C02*) 8192 (const nomodify byte*) PPU_PALETTE = (byte*) 16128 @@ -54,7 +59,8 @@ (byte) RICOH_2C02::PPUSCROLL (volatile byte) RICOH_2C02::PPUSTATUS loadstore (const byte) SIZEOF_BYTE = (byte) 1 -(const byte*) SPRITES[] = { (byte) $80, (byte) $36, (byte) 2, (byte) $80, (byte) $80, (byte) $37, (byte) 2, (byte) $88, (byte) $88, (byte) $38, (byte) 2, (byte) $80, (byte) $88, (byte) $39, (byte) 2, (byte) $88 } +(const byte) SIZEOF_STRUCT_OBJECTATTRIBUTE = (byte) 4 +(const struct ObjectAttribute*) SPRITES[] = { { y: (byte) $80, tile: (byte) $36, attributes: (byte) 2, x: (byte) $80 }, { y: (byte) $80, tile: (byte) $37, attributes: (byte) 2, x: (byte) $88 }, { y: (byte) $88, tile: (byte) $38, attributes: (byte) 2, x: (byte) $80 }, { y: (byte) $88, tile: (byte) $39, attributes: (byte) 2, x: (byte) $88 } } (const byte*) TILES[] = kickasm {{ .import binary "smb1_chr.bin" }} (const to_nomodify void()**) VECTORS[] = { &interrupt(HARDWARE_STACK)(void()) vblank(), &(void()) main(), (void()*) 0 } @@ -67,11 +73,10 @@ (byte) initPaletteData::i#2 reg byte x 1334.6666666666667 (void()) initSpriteData() (label) initSpriteData::@1 -(label) initSpriteData::@2 (label) initSpriteData::@return (byte) initSpriteData::i -(byte) initSpriteData::i#1 reg byte x 2002.0 -(byte) initSpriteData::i#2 reg byte x 1668.3333333333335 +(byte) initSpriteData::i#1 reg byte x 1501.5 +(byte) initSpriteData::i#2 reg byte x 2002.0 (void()) main() (label) main::@1 (label) main::@2