From 5b2f43a40c1e21d3da26533a618a5104b17cd6dc Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Tue, 22 Sep 2020 22:24:25 +0200 Subject: [PATCH] Added IRQ to mega65 memory banking example. --- src/test/kc/examples/mega65/banked-music.c | 85 +- src/test/ref/examples/mega65/banked-music.asm | 234 +- src/test/ref/examples/mega65/banked-music.cfg | 161 +- src/test/ref/examples/mega65/banked-music.log | 2116 +++++++++++------ src/test/ref/examples/mega65/banked-music.sym | 72 +- 5 files changed, 1755 insertions(+), 913 deletions(-) diff --git a/src/test/kc/examples/mega65/banked-music.c b/src/test/kc/examples/mega65/banked-music.c index 5b42e8c7a..2005fe992 100644 --- a/src/test/kc/examples/mega65/banked-music.c +++ b/src/test/kc/examples/mega65/banked-music.c @@ -1,4 +1,4 @@ -// SID music located in another bank being played using memory mapping on MEGA65 +// SID music located in another bank being played in a raster IRQ using memory mapping on the MEGA65 // Music is Cybernoid II by Jeroen Tel released in 1988 by Hewson https://csdb.dk/sid/?id=28140 // SID relocated using http://www.linusakesson.net/software/sidreloc/index.php #pragma target(mega65) @@ -8,6 +8,20 @@ void main() { // Stop IRQ's asm { sei } + // Map memory to BANK 0 : 0x00XXXX - giving access to I/O + memoryRemap(0,0,0); + // Enable MEGA65 features + VICIII->KEY = 0x47; + VICIII->KEY = 0x53; + // Enable 48MHz fast mode + VICIV->CONTROLB |= 0x40; + VICIV->CONTROLC |= 0x40; + // no kernal or BASIC rom visible + *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK; + *PROCPORT = PROCPORT_RAM_IO; + // open sideborder + VICIV->SIDBDRWD_LO = 1; + // Remap [$4000-$5fff] to point to [$10000-$11fff] memoryRemapBlock(0x40, 0x100); // Transfer banked code/data to upper memory ($11000) @@ -18,29 +32,50 @@ void main() { // Reset memory mapping memoryRemap(0,0,0); - // Pointer to (unmapped) $4000 used for overwriting to demonstrate the mapping works - char* mem_destroy = MUSIC; - - for(;;) { - // Overwrite data in the unmapped memory where the music is mapped in (to demonstrate that mapping works) - *mem_destroy = 0; - if(++mem_destroy==MUSIC_END) mem_destroy = MUSIC; - // Wait for the raster - while(VICII->RASTER!=0xff) ; - // Color border - (VICII->BORDER_COLOR)++; - // Remap memory to put music at $4000 - memoryRemapBlock(0x40, 0x100); - // Play remapped SID - (*musicPlay)(); - // Reset memory mapping - memoryRemap(0,0,0); - // Color border - (VICII->BORDER_COLOR)--; - // Wait for the raster - while(VICII->RASTER==0xff) ; - } + // Set up raster interrupts C64 style + // Disable CIA 1 Timer IRQ + CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR; + // Set raster line to 0xff + VICII->RASTER = 0xff; + VICII->CONTROL1 &= 0x7f; + // Enable Raster Interrupt + VICII->IRQ_ENABLE = IRQ_RASTER; + // Set the IRQ routine + *HARDWARE_IRQ = &irq; + // Enable IRQ + asm { cli } + + // Loop forever - while copying unmapped MUSIC memory to screen (to demonstrate that mapping works) + for(;;) + for(char i=0;i<240;i++) + DEFAULT_SCREEN[i] = MUSIC[i]; + +} + +// Index used to destroy unmapped music memory (to demonstrate that mapping works) +volatile char mem_destroy_i = 0; + +// Raster IRQ routine +interrupt(hardware_stack) void irq() { + // Acknowledge the IRQ + VICII->IRQ_STATUS = IRQ_RASTER; + // Overwrite data in the unmapped memory where the music is mapped in (to demonstrate that mapping works) + MUSIC[mem_destroy_i++]++; + // Wait for the raster + while(VICII->RASTER!=0xff) ; + // Color border + (VICII->BORDER_COLOR)++; + // Remap memory to put music at $4000 + memoryRemapBlock(0x40, 0x100); + // Play remapped SID + (*musicPlay)(); + // Reset memory mapping + memoryRemap(0,0,0); + // Wait for the raster + while(VICII->RASTER==0xff) ; + // Color border + (VICII->BORDER_COLOR)--; } // Array containing the banked upper memory code/data to be transferred to upper memory before execution @@ -48,7 +83,7 @@ char upperCodeData[] = kickasm {{ .segmentout [segments="Banked"] }}; -// Code and data to be put into upper memory, which will be banked into $4000 +// Code and data to be put into upper memory, which will be banked into $4000 by mempry mapping #pragma code_seg(CodeBanked) #pragma data_seg(DataBanked) @@ -57,10 +92,8 @@ __address(0x4000) char MUSIC[] = kickasm(resource "Cybernoid_II_4000.sid") {{ .const music = LoadSid("Cybernoid_II_4000.sid") .fill music.size, music.getData(i) }}; - // Address after the end of the music char * const MUSIC_END = 0x5200; - // Pointer to the music init routine void()* musicInit = (void()*) MUSIC; // Pointer to the music play routine diff --git a/src/test/ref/examples/mega65/banked-music.asm b/src/test/ref/examples/mega65/banked-music.asm index 6c4ab18f8..210a2f9f4 100644 --- a/src/test/ref/examples/mega65/banked-music.asm +++ b/src/test/ref/examples/mega65/banked-music.asm @@ -1,4 +1,4 @@ -// SID music located in another bank being played using memory mapping on MEGA65 +// SID music located in another bank being played in a raster IRQ using memory mapping on the MEGA65 // Music is Cybernoid II by Jeroen Tel released in 1988 by Hewson https://csdb.dk/sid/?id=28140 // SID relocated using http://www.linusakesson.net/software/sidreloc/index.php .cpu _45gs02 @@ -14,27 +14,154 @@ .segment Basic .byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0 .byte $15, $20, $14, $00, $9e, $20 // 20 SYS -.text toIntString(main) // NNNN +.text toIntString(__start) // NNNN .byte $00, $00, $00 // + // Value that disables all CIA interrupts when stored to the CIA Interrupt registers + .const CIA_INTERRUPT_CLEAR = $7f + // Bits for the VICII IRQ Status/Enable Registers + .const IRQ_RASTER = 1 + // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written + .const PROCPORT_DDR_MEMORY_MASK = 7 + // RAM in 0xA000, 0xE000 I/O in 0xD000 + .const PROCPORT_RAM_IO = 5 + .const OFFSET_STRUCT_MOS4569_VICIII_KEY = $2f + .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLB = $31 + .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLC = $54 + .const OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO = $5c + .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12 + .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11 + .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a + .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19 .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 + // Processor port data direction register + .label PROCPORT_DDR = 0 + // Processor Port Register controlling RAM/ROM configuration and the datasette + .label PROCPORT = 1 // The VIC-II MOS 6567/6569 .label VICII = $d000 + // The VIC III MOS 4567/4569 + .label VICIII = $d000 + // The VIC IV + .label VICIV = $d000 + // Default address of screen character matrix + .label DEFAULT_SCREEN = $800 + // The CIA#1: keyboard matrix, joystick #1/#2 + .label CIA1 = $dc00 + // The vector used when the HARDWARE serves IRQ interrupts + .label HARDWARE_IRQ = $fffe // Address after the end of the music .label MUSIC_END = $5200 // Pointer to the music init routine .label musicInit = MUSIC // Pointer to the music play routine .label musicPlay = MUSIC+3 + // Index used to destroy unmapped music memory (to demonstrate that mapping works) + .label mem_destroy_i = $a .segment Code +__start: { + // mem_destroy_i = 0 + lda #0 + sta.z mem_destroy_i + jsr main + rts +} +// Raster IRQ routine +irq: { + pha + txa + pha + tya + pha + // VICII->IRQ_STATUS = IRQ_RASTER + // Acknowledge the IRQ + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS + // MUSIC[mem_destroy_i++]++; + ldx.z mem_destroy_i + inc MUSIC,x + inc.z mem_destroy_i + // Wait for the raster + __b1: + // while(VICII->RASTER!=0xff) + lda #$ff + cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + bne __b1 + // (VICII->BORDER_COLOR)++; + inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + // memoryRemapBlock(0x40, 0x100) + // Remap memory to put music at $4000 + jsr memoryRemapBlock + // (*musicPlay)() + // Play remapped SID + jsr musicPlay + // memoryRemap(0,0,0) + // Reset memory mapping + lda #<0 + sta.z memoryRemap.upperPageOffset + sta.z memoryRemap.upperPageOffset+1 + ldz #0 + sta.z memoryRemap.lowerPageOffset + sta.z memoryRemap.lowerPageOffset+1 + jsr memoryRemap + // Wait for the raster + __b3: + // while(VICII->RASTER==0xff) + lda #$ff + cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + beq __b3 + // (VICII->BORDER_COLOR)--; + dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + // } + pla + tay + pla + tax + pla + rti +} main: { .label dst = 2 .label src = 4 - // Pointer to (unmapped) $4000 used for overwriting to demonstrate the mapping works - .label mem_destroy = 6 // asm // Stop IRQ's sei + // memoryRemap(0,0,0) + // Map memory to BANK 0 : 0x00XXXX - giving access to I/O + lda #<0 + sta.z memoryRemap.upperPageOffset + sta.z memoryRemap.upperPageOffset+1 + ldz #0 + sta.z memoryRemap.lowerPageOffset + sta.z memoryRemap.lowerPageOffset+1 + jsr memoryRemap + // VICIII->KEY = 0x47 + // Enable MEGA65 features + lda #$47 + sta VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY + // VICIII->KEY = 0x53 + lda #$53 + sta VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY + // VICIV->CONTROLB |= 0x40 + // Enable 48MHz fast mode + lda #$40 + ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB + // VICIV->CONTROLC |= 0x40 + lda #$40 + ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC + // *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK + // no kernal or BASIC rom visible + lda #PROCPORT_DDR_MEMORY_MASK + sta PROCPORT_DDR + // *PROCPORT = PROCPORT_RAM_IO + lda #PROCPORT_RAM_IO + sta PROCPORT + // VICIV->SIDBDRWD_LO = 1 + // open sideborder + lda #1 + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO // memoryRemapBlock(0x40, 0x100) // Remap [$4000-$5fff] to point to [$10000-$11fff] jsr memoryRemapBlock @@ -69,59 +196,44 @@ main: { sta.z memoryRemap.lowerPageOffset sta.z memoryRemap.lowerPageOffset+1 jsr memoryRemap - lda #MUSIC - sta.z mem_destroy+1 + // CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR + // Set up raster interrupts C64 style + // Disable CIA 1 Timer IRQ + lda #CIA_INTERRUPT_CLEAR + sta CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT + // VICII->RASTER = 0xff + // Set raster line to 0xff + lda #$ff + sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + // VICII->CONTROL1 &= 0x7f + lda #$7f + and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + // VICII->IRQ_ENABLE = IRQ_RASTER + // Enable Raster Interrupt + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE + // *HARDWARE_IRQ = &irq + // Set the IRQ routine + lda #irq + sta HARDWARE_IRQ+1 + // asm + // Enable IRQ + cli __b4: - // *mem_destroy = 0 - // Overwrite data in the unmapped memory where the music is mapped in (to demonstrate that mapping works) - lda #0 - tay - sta (mem_destroy),y - // if(++mem_destroy==MUSIC_END) - inw.z mem_destroy - lda.z mem_destroy+1 - cmp #>MUSIC_END - bne __b10 - lda.z mem_destroy - cmp #MUSIC - sta.z mem_destroy+1 - __b10: - // Wait for the raster - // while(VICII->RASTER!=0xff) - lda #$ff - cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER - bne __b10 - // (VICII->BORDER_COLOR)++; - inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - // memoryRemapBlock(0x40, 0x100) - // Remap memory to put music at $4000 - jsr memoryRemapBlock - // (*musicPlay)() - // Play remapped SID - jsr musicPlay - // memoryRemap(0,0,0) - // Reset memory mapping - lda #<0 - sta.z memoryRemap.upperPageOffset - sta.z memoryRemap.upperPageOffset+1 - ldz #0 - sta.z memoryRemap.lowerPageOffset - sta.z memoryRemap.lowerPageOffset+1 - jsr memoryRemap - // (VICII->BORDER_COLOR)--; - dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - // Wait for the raster - __b7: - // while(VICII->RASTER==0xff) - lda #$ff - cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER - beq __b7 + // for(char i=0;i<240;i++) + cpx #$f0 + bcc __b5 + ldx #0 + jmp __b4 + __b5: + // DEFAULT_SCREEN[i] = MUSIC[i] + lda MUSIC,x + sta DEFAULT_SCREEN,x + // for(char i=0;i<240;i++) + inx jmp __b4 __b2: // *dst++ = *src++ @@ -180,16 +292,16 @@ memoryRemapBlock: { // - If block 5 ($a000-$bfff) is remapped it will point to upperPageOffset*$100 + $a000. // - If block 6 ($c000-$dfff) is remapped it will point to upperPageOffset*$100 + $c000. // - If block 7 ($e000-$ffff) is remapped it will point to upperPageOffset*$100 + $e000. -// memoryRemap(byte register(Z) remapBlocks, word zp(8) lowerPageOffset, word zp($a) upperPageOffset) +// memoryRemap(byte register(Z) remapBlocks, word zp(6) lowerPageOffset, word zp(8) upperPageOffset) memoryRemap: { .label aVal = $fc .label xVal = $fd .label yVal = $fe .label zVal = $ff - .label __1 = $c - .label __6 = $d - .label lowerPageOffset = 8 - .label upperPageOffset = $a + .label __1 = $b + .label __6 = $c + .label lowerPageOffset = 6 + .label upperPageOffset = 8 // (word) memoryRemap::lowerPageOffset#3 - [30] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f - [31] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 - [32] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 - [33] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#3 - [34] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 - [35] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (byte) $f0 - [36] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#3 - [37] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f - [38] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 - [39] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 +memoryRemap: scope:[memoryRemap] from irq::@5 main main::@3 memoryRemapBlock + [46] (word) memoryRemap::upperPageOffset#4 ← phi( irq::@5/(byte) 0 main/(byte) 0 main::@3/(byte) 0 memoryRemapBlock/(const word) memoryRemapBlock::pageOffset#0 ) + [46] (byte) memoryRemap::remapBlocks#4 ← phi( irq::@5/(byte) 0 main/(byte) 0 main::@3/(byte) 0 memoryRemapBlock/(const byte) memoryRemapBlock::blockBits#0 ) + [46] (word) memoryRemap::lowerPageOffset#4 ← phi( irq::@5/(byte) 0 main/(byte) 0 main::@3/(byte) 0 memoryRemapBlock/(const word) memoryRemapBlock::pageOffset#0 ) + [47] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#4 + [48] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 + [49] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#4 << (byte) 4 + [50] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#4 + [51] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f + [52] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 + [53] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 + [54] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#4 + [55] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 + [56] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (byte) $f0 + [57] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#4 + [58] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f + [59] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 + [60] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } to:memoryRemap::@return memoryRemap::@return: scope:[memoryRemap] from memoryRemap - [41] return + [62] return to:@return diff --git a/src/test/ref/examples/mega65/banked-music.log b/src/test/ref/examples/mega65/banked-music.log index 506c9dd94..af7ea628b 100644 --- a/src/test/ref/examples/mega65/banked-music.log +++ b/src/test/ref/examples/mega65/banked-music.log @@ -3,8 +3,10 @@ Resolved forward reference upperCodeData to (const byte*) upperCodeData Resolved forward reference MUSIC to (const byte*) MUSIC Resolved forward reference MUSIC_END to (const nomodify byte*) MUSIC_END Resolved forward reference musicInit to (void()*) musicInit +Resolved forward reference irq to interrupt(HARDWARE_STACK)(void()) irq() +Resolved forward reference MUSIC to (const byte*) MUSIC +Resolved forward reference MUSIC to (const byte*) MUSIC Resolved forward reference MUSIC to (const byte*) MUSIC -Resolved forward reference MUSIC_END to (const nomodify byte*) MUSIC_END Resolved forward reference MUSIC to (const byte*) MUSIC Resolved forward reference musicPlay to (void()*) musicPlay Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx @@ -13,21 +15,21 @@ Inlined call call __init CONTROL FLOW GRAPH SSA (void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerPageOffset , (word) memoryRemap::upperPageOffset) -memoryRemap: scope:[memoryRemap] from main::@11 main::@3 memoryRemapBlock - (word) memoryRemap::upperPageOffset#3 ← phi( main::@11/(word) memoryRemap::upperPageOffset#2 main::@3/(word) memoryRemap::upperPageOffset#1 memoryRemapBlock/(word) memoryRemap::upperPageOffset#0 ) - (byte) memoryRemap::remapBlocks#3 ← phi( main::@11/(byte) memoryRemap::remapBlocks#2 main::@3/(byte) memoryRemap::remapBlocks#1 memoryRemapBlock/(byte) memoryRemap::remapBlocks#0 ) - (word) memoryRemap::lowerPageOffset#3 ← phi( main::@11/(word) memoryRemap::lowerPageOffset#2 main::@3/(word) memoryRemap::lowerPageOffset#1 memoryRemapBlock/(word) memoryRemap::lowerPageOffset#0 ) - (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#3 +memoryRemap: scope:[memoryRemap] from irq::@5 main main::@3 memoryRemapBlock + (word) memoryRemap::upperPageOffset#4 ← phi( irq::@5/(word) memoryRemap::upperPageOffset#3 main/(word) memoryRemap::upperPageOffset#1 main::@3/(word) memoryRemap::upperPageOffset#2 memoryRemapBlock/(word) memoryRemap::upperPageOffset#0 ) + (byte) memoryRemap::remapBlocks#4 ← phi( irq::@5/(byte) memoryRemap::remapBlocks#3 main/(byte) memoryRemap::remapBlocks#1 main::@3/(byte) memoryRemap::remapBlocks#2 memoryRemapBlock/(byte) memoryRemap::remapBlocks#0 ) + (word) memoryRemap::lowerPageOffset#4 ← phi( irq::@5/(word) memoryRemap::lowerPageOffset#3 main/(word) memoryRemap::lowerPageOffset#1 main::@3/(word) memoryRemap::lowerPageOffset#2 memoryRemapBlock/(word) memoryRemap::lowerPageOffset#0 ) + (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#4 *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 - (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#3 << (number) 4 - (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#3 + (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#4 << (number) 4 + (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#4 (number~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (number) $f (number~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (number~) memoryRemap::$3 *((const byte*) memoryRemap::xVal) ← (number~) memoryRemap::$4 - (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#3 + (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#4 *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 - (number~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (number) $f0 - (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#3 + (number~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (number) $f0 + (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#4 (number~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (number) $f (number~) memoryRemap::$9 ← (number~) memoryRemap::$6 | (number~) memoryRemap::$8 *((const byte*) memoryRemap::zVal) ← (number~) memoryRemap::$9 @@ -38,9 +40,9 @@ memoryRemap::@return: scope:[memoryRemap] from memoryRemap to:@return (void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) -memoryRemapBlock: scope:[memoryRemapBlock] from main main::@6 - (byte) memoryRemapBlock::blockPage#2 ← phi( main/(byte) memoryRemapBlock::blockPage#0 main::@6/(byte) memoryRemapBlock::blockPage#1 ) - (word) memoryRemapBlock::memoryPage#2 ← phi( main/(word) memoryRemapBlock::memoryPage#0 main::@6/(word) memoryRemapBlock::memoryPage#1 ) +memoryRemapBlock: scope:[memoryRemapBlock] from irq::@2 main::@7 + (byte) memoryRemapBlock::blockPage#2 ← phi( irq::@2/(byte) memoryRemapBlock::blockPage#1 main::@7/(byte) memoryRemapBlock::blockPage#0 ) + (word) memoryRemapBlock::memoryPage#2 ← phi( irq::@2/(word) memoryRemapBlock::memoryPage#1 main::@7/(word) memoryRemapBlock::memoryPage#0 ) (word~) memoryRemapBlock::$0 ← (word) memoryRemapBlock::memoryPage#2 - (byte) memoryRemapBlock::blockPage#2 (word) memoryRemapBlock::pageOffset#0 ← (word~) memoryRemapBlock::$0 (number~) memoryRemapBlock::$1 ← (byte) memoryRemapBlock::blockPage#2 / (number) $20 @@ -61,19 +63,32 @@ memoryRemapBlock::@return: scope:[memoryRemapBlock] from memoryRemapBlock::@1 (void()) main() main: scope:[main] from __start::@1 asm { sei } + (byte) memoryRemap::remapBlocks#1 ← (number) 0 + (word) memoryRemap::lowerPageOffset#1 ← (number) 0 + (word) memoryRemap::upperPageOffset#1 ← (number) 0 + call memoryRemap + to:main::@7 +main::@7: scope:[main] from main + *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (number) $47 + *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (number) $53 + *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | (number) $40 + *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | (number) $40 + *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK + *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO + *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) ← (number) 1 (byte) memoryRemapBlock::blockPage#0 ← (number) $40 (word) memoryRemapBlock::memoryPage#0 ← (number) $100 call memoryRemapBlock - to:main::@9 -main::@9: scope:[main] from main + to:main::@8 +main::@8: scope:[main] from main::@7 (byte*) main::src#0 ← (const byte*) upperCodeData (byte*) main::dst#0 ← (const byte*) MUSIC to:main::@1 -main::@1: scope:[main] from main::@2 main::@9 - (byte*) main::src#3 ← phi( main::@2/(byte*) main::src#1 main::@9/(byte*) main::src#0 ) - (byte*) main::dst#2 ← phi( main::@2/(byte*) main::dst#1 main::@9/(byte*) main::dst#0 ) - (bool~) main::$3 ← (byte*) main::dst#2 < (const nomodify byte*) MUSIC_END - if((bool~) main::$3) goto main::@2 +main::@1: scope:[main] from main::@2 main::@8 + (byte*) main::src#3 ← phi( main::@2/(byte*) main::src#1 main::@8/(byte*) main::src#0 ) + (byte*) main::dst#2 ← phi( main::@2/(byte*) main::dst#1 main::@8/(byte*) main::dst#0 ) + (bool~) main::$4 ← (byte*) main::dst#2 < (const nomodify byte*) MUSIC_END + if((bool~) main::$4) goto main::@2 to:main::@3 main::@2: scope:[main] from main::@1 (byte*) main::dst#3 ← phi( main::@1/(byte*) main::dst#2 ) @@ -84,62 +99,77 @@ main::@2: scope:[main] from main::@1 to:main::@1 main::@3: scope:[main] from main::@1 call *((const void()*) musicInit) - (byte) memoryRemap::remapBlocks#1 ← (number) 0 - (word) memoryRemap::lowerPageOffset#1 ← (number) 0 - (word) memoryRemap::upperPageOffset#1 ← (number) 0 - call memoryRemap - to:main::@10 -main::@10: scope:[main] from main::@3 - (byte*) main::mem_destroy#0 ← (const byte*) MUSIC - to:main::@4 -main::@4: scope:[main] from main::@10 main::@7 - (byte*) main::mem_destroy#3 ← phi( main::@10/(byte*) main::mem_destroy#0 main::@7/(byte*) main::mem_destroy#4 ) - *((byte*) main::mem_destroy#3) ← (number) 0 - (byte*) main::mem_destroy#1 ← ++ (byte*) main::mem_destroy#3 - (bool~) main::$4 ← (byte*) main::mem_destroy#1 == (const nomodify byte*) MUSIC_END - (bool~) main::$5 ← ! (bool~) main::$4 - if((bool~) main::$5) goto main::@5 - to:main::@8 -main::@8: scope:[main] from main::@4 - (byte*) main::mem_destroy#2 ← (const byte*) MUSIC - to:main::@5 -main::@5: scope:[main] from main::@4 main::@5 main::@8 - (byte*) main::mem_destroy#8 ← phi( main::@4/(byte*) main::mem_destroy#1 main::@5/(byte*) main::mem_destroy#8 main::@8/(byte*) main::mem_destroy#2 ) - (bool~) main::$6 ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) != (number) $ff - if((bool~) main::$6) goto main::@5 - to:main::@6 -main::@6: scope:[main] from main::@5 - (byte*) main::mem_destroy#7 ← phi( main::@5/(byte*) main::mem_destroy#8 ) - *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) - (byte) memoryRemapBlock::blockPage#1 ← (number) $40 - (word) memoryRemapBlock::memoryPage#1 ← (number) $100 - call memoryRemapBlock - to:main::@11 -main::@11: scope:[main] from main::@6 - (byte*) main::mem_destroy#6 ← phi( main::@6/(byte*) main::mem_destroy#7 ) - call *((const void()*) musicPlay) (byte) memoryRemap::remapBlocks#2 ← (number) 0 (word) memoryRemap::lowerPageOffset#2 ← (number) 0 (word) memoryRemap::upperPageOffset#2 ← (number) 0 call memoryRemap - to:main::@12 -main::@12: scope:[main] from main::@11 - (byte*) main::mem_destroy#5 ← phi( main::@11/(byte*) main::mem_destroy#6 ) - *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) - to:main::@7 -main::@7: scope:[main] from main::@12 main::@7 - (byte*) main::mem_destroy#4 ← phi( main::@12/(byte*) main::mem_destroy#5 main::@7/(byte*) main::mem_destroy#4 ) - (bool~) main::$12 ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) == (number) $ff - if((bool~) main::$12) goto main::@7 + to:main::@9 +main::@9: scope:[main] from main::@3 + *((byte*)(const nomodify struct MOS6526_CIA*) CIA1+(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR + *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (number) $ff + *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & (number) $7f + *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER + *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_STACK)(void()) irq() + asm { cli } to:main::@4 +main::@4: scope:[main] from main::@5 main::@9 + (byte) main::i#0 ← (byte) 0 + to:main::@5 +main::@5: scope:[main] from main::@4 main::@6 + (byte) main::i#2 ← phi( main::@4/(byte) main::i#0 main::@6/(byte) main::i#1 ) + (bool~) main::$5 ← (byte) main::i#2 < (number) $f0 + if((bool~) main::$5) goto main::@6 + to:main::@4 +main::@6: scope:[main] from main::@5 + (byte) main::i#3 ← phi( main::@5/(byte) main::i#2 ) + *((const nomodify byte*) DEFAULT_SCREEN + (byte) main::i#3) ← *((const byte*) MUSIC + (byte) main::i#3) + (byte) main::i#1 ← ++ (byte) main::i#3 + to:main::@5 main::@return: scope:[main] from return to:@return +interrupt(HARDWARE_STACK)(void()) irq() +irq: scope:[irq] from + *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER + *((const byte*) MUSIC + (volatile byte) mem_destroy_i) ← ++ *((const byte*) MUSIC + (volatile byte) mem_destroy_i) + (volatile byte) mem_destroy_i ← ++ (volatile byte) mem_destroy_i + to:irq::@1 +irq::@1: scope:[irq] from irq irq::@1 + (bool~) irq::$6 ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) != (number) $ff + if((bool~) irq::$6) goto irq::@1 + to:irq::@2 +irq::@2: scope:[irq] from irq::@1 + *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) + (byte) memoryRemapBlock::blockPage#1 ← (number) $40 + (word) memoryRemapBlock::memoryPage#1 ← (number) $100 + call memoryRemapBlock + to:irq::@5 +irq::@5: scope:[irq] from irq::@2 + call *((const void()*) musicPlay) + (byte) memoryRemap::remapBlocks#3 ← (number) 0 + (word) memoryRemap::lowerPageOffset#3 ← (number) 0 + (word) memoryRemap::upperPageOffset#3 ← (number) 0 + call memoryRemap + to:irq::@6 +irq::@6: scope:[irq] from irq::@5 + to:irq::@3 +irq::@3: scope:[irq] from irq::@3 irq::@6 + (bool~) irq::$7 ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) == (number) $ff + if((bool~) irq::$7) goto irq::@3 + to:irq::@4 +irq::@4: scope:[irq] from irq::@3 + *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) + to:irq::@return +irq::@return: scope:[irq] from irq::@4 + return + to:@return + (void()) __start() __start: scope:[__start] from to:__start::__init1 __start::__init1: scope:[__start] from __start + (volatile byte) mem_destroy_i ← (byte) 0 to:__start::@1 __start::@1: scope:[__start] from __start::__init1 call main @@ -151,6 +181,11 @@ __start::@return: scope:[__start] from __start::@2 to:@return SYMBOL TABLE SSA +(const nomodify struct MOS6526_CIA*) CIA1 = (struct MOS6526_CIA*)(number) $dc00 +(const nomodify byte) CIA_INTERRUPT_CLEAR = (byte) $7f +(const nomodify byte*) DEFAULT_SCREEN = (byte*)(number) $800 +(const nomodify void()**) HARDWARE_IRQ = (void()**)(number) $fffe +(const nomodify byte) IRQ_RASTER = (byte) 1 (byte) MEGA65_VICIV::ALPHADELAY (byte) MEGA65_VICIV::B0PIX (byte) MEGA65_VICIV::B0_ADDR @@ -439,24 +474,42 @@ SYMBOL TABLE SSA .fill music.size, music.getData(i) }} (const nomodify byte*) MUSIC_END = (byte*)(number) $5200 +(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB = (byte) $31 +(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC = (byte) $54 +(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO = (byte) $5c +(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY = (byte) $2f +(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = (byte) $d (const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = (byte) $20 +(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = (byte) $11 +(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = (byte) $1a +(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = (byte) $19 (const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER = (byte) $12 +(const nomodify byte*) PROCPORT = (byte*)(number) 1 +(const nomodify byte*) PROCPORT_DDR = (byte*)(number) 0 +(const nomodify byte) PROCPORT_DDR_MEMORY_MASK = (byte) 7 +(const nomodify byte) PROCPORT_RAM_IO = (byte) 5 (const nomodify struct MOS6569_VICII*) VICII = (struct MOS6569_VICII*)(number) $d000 +(const nomodify struct MOS4569_VICIII*) VICIII = (struct MOS4569_VICIII*)(number) $d000 +(const nomodify struct MEGA65_VICIV*) VICIV = (struct MEGA65_VICIV*)(number) $d000 (void()) __start() (label) __start::@1 (label) __start::@2 (label) __start::@return (label) __start::__init1 +interrupt(HARDWARE_STACK)(void()) irq() +(bool~) irq::$6 +(bool~) irq::$7 +(label) irq::@1 +(label) irq::@2 +(label) irq::@3 +(label) irq::@4 +(label) irq::@5 +(label) irq::@6 +(label) irq::@return (void()) main() -(bool~) main::$12 -(bool~) main::$3 (bool~) main::$4 (bool~) main::$5 -(bool~) main::$6 (label) main::@1 -(label) main::@10 -(label) main::@11 -(label) main::@12 (label) main::@2 (label) main::@3 (label) main::@4 @@ -471,21 +524,17 @@ SYMBOL TABLE SSA (byte*) main::dst#1 (byte*) main::dst#2 (byte*) main::dst#3 -(byte*) main::mem_destroy -(byte*) main::mem_destroy#0 -(byte*) main::mem_destroy#1 -(byte*) main::mem_destroy#2 -(byte*) main::mem_destroy#3 -(byte*) main::mem_destroy#4 -(byte*) main::mem_destroy#5 -(byte*) main::mem_destroy#6 -(byte*) main::mem_destroy#7 -(byte*) main::mem_destroy#8 +(byte) main::i +(byte) main::i#0 +(byte) main::i#1 +(byte) main::i#2 +(byte) main::i#3 (byte*) main::src (byte*) main::src#0 (byte*) main::src#1 (byte*) main::src#2 (byte*) main::src#3 +(volatile byte) mem_destroy_i loadstore (void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerPageOffset , (word) memoryRemap::upperPageOffset) (byte~) memoryRemap::$0 (byte~) memoryRemap::$1 @@ -504,16 +553,19 @@ SYMBOL TABLE SSA (word) memoryRemap::lowerPageOffset#1 (word) memoryRemap::lowerPageOffset#2 (word) memoryRemap::lowerPageOffset#3 +(word) memoryRemap::lowerPageOffset#4 (byte) memoryRemap::remapBlocks (byte) memoryRemap::remapBlocks#0 (byte) memoryRemap::remapBlocks#1 (byte) memoryRemap::remapBlocks#2 (byte) memoryRemap::remapBlocks#3 +(byte) memoryRemap::remapBlocks#4 (word) memoryRemap::upperPageOffset (word) memoryRemap::upperPageOffset#0 (word) memoryRemap::upperPageOffset#1 (word) memoryRemap::upperPageOffset#2 (word) memoryRemap::upperPageOffset#3 +(word) memoryRemap::upperPageOffset#4 (const byte*) memoryRemap::xVal = (byte*)(number) $fd (const byte*) memoryRemap::yVal = (byte*)(number) $fe (const byte*) memoryRemap::zVal = (byte*)(number) $ff @@ -543,12 +595,12 @@ SYMBOL TABLE SSA }} Adding number conversion cast (unumber) 3 in -Adding number conversion cast (unumber) 4 in (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#3 << (number) 4 +Adding number conversion cast (unumber) 4 in (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#4 << (number) 4 Adding number conversion cast (unumber) $f in (number~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (number) $f Adding number conversion cast (unumber) memoryRemap::$3 in (number~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (unumber)(number) $f Adding number conversion cast (unumber) memoryRemap::$4 in (number~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (unumber~) memoryRemap::$3 -Adding number conversion cast (unumber) $f0 in (number~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (number) $f0 -Adding number conversion cast (unumber) memoryRemap::$6 in (number~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (unumber)(number) $f0 +Adding number conversion cast (unumber) $f0 in (number~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (number) $f0 +Adding number conversion cast (unumber) memoryRemap::$6 in (number~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (unumber)(number) $f0 Adding number conversion cast (unumber) $f in (number~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (number) $f Adding number conversion cast (unumber) memoryRemap::$8 in (number~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (unumber)(number) $f Adding number conversion cast (unumber) memoryRemap::$9 in (number~) memoryRemap::$9 ← (unumber~) memoryRemap::$6 | (unumber~) memoryRemap::$8 @@ -556,37 +608,60 @@ Adding number conversion cast (unumber) $20 in (number~) memoryRemapBlock::$1 Adding number conversion cast (unumber) memoryRemapBlock::$1 in (number~) memoryRemapBlock::$1 ← (byte) memoryRemapBlock::blockPage#2 / (unumber)(number) $20 Adding number conversion cast (unumber) 1 in (number~) memoryRemapBlock::$2 ← (number) 1 << (byte) memoryRemapBlock::block#0 Adding number conversion cast (unumber) memoryRemapBlock::$2 in (number~) memoryRemapBlock::$2 ← (unumber)(number) 1 << (byte) memoryRemapBlock::block#0 -Adding number conversion cast (unumber) $40 in (byte) memoryRemapBlock::blockPage#0 ← (number) $40 -Adding number conversion cast (unumber) $100 in (word) memoryRemapBlock::memoryPage#0 ← (number) $100 Adding number conversion cast (unumber) 0 in (byte) memoryRemap::remapBlocks#1 ← (number) 0 Adding number conversion cast (unumber) 0 in (word) memoryRemap::lowerPageOffset#1 ← (number) 0 Adding number conversion cast (unumber) 0 in (word) memoryRemap::upperPageOffset#1 ← (number) 0 -Adding number conversion cast (unumber) 0 in *((byte*) main::mem_destroy#3) ← (number) 0 -Adding number conversion cast (unumber) $ff in (bool~) main::$6 ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) != (number) $ff -Adding number conversion cast (unumber) $40 in (byte) memoryRemapBlock::blockPage#1 ← (number) $40 -Adding number conversion cast (unumber) $100 in (word) memoryRemapBlock::memoryPage#1 ← (number) $100 +Adding number conversion cast (unumber) $47 in *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (number) $47 +Adding number conversion cast (unumber) $53 in *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (number) $53 +Adding number conversion cast (unumber) $40 in *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | (number) $40 +Adding number conversion cast (unumber) $40 in *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | (number) $40 +Adding number conversion cast (unumber) 1 in *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) ← (number) 1 +Adding number conversion cast (unumber) $40 in (byte) memoryRemapBlock::blockPage#0 ← (number) $40 +Adding number conversion cast (unumber) $100 in (word) memoryRemapBlock::memoryPage#0 ← (number) $100 Adding number conversion cast (unumber) 0 in (byte) memoryRemap::remapBlocks#2 ← (number) 0 Adding number conversion cast (unumber) 0 in (word) memoryRemap::lowerPageOffset#2 ← (number) 0 Adding number conversion cast (unumber) 0 in (word) memoryRemap::upperPageOffset#2 ← (number) 0 -Adding number conversion cast (unumber) $ff in (bool~) main::$12 ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) == (number) $ff +Adding number conversion cast (unumber) $ff in *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (number) $ff +Adding number conversion cast (unumber) $7f in *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & (number) $7f +Adding number conversion cast (unumber) $f0 in (bool~) main::$5 ← (byte) main::i#2 < (number) $f0 +Adding number conversion cast (unumber) $ff in (bool~) irq::$6 ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) != (number) $ff +Adding number conversion cast (unumber) $40 in (byte) memoryRemapBlock::blockPage#1 ← (number) $40 +Adding number conversion cast (unumber) $100 in (word) memoryRemapBlock::memoryPage#1 ← (number) $100 +Adding number conversion cast (unumber) 0 in (byte) memoryRemap::remapBlocks#3 ← (number) 0 +Adding number conversion cast (unumber) 0 in (word) memoryRemap::lowerPageOffset#3 ← (number) 0 +Adding number conversion cast (unumber) 0 in (word) memoryRemap::upperPageOffset#3 ← (number) 0 +Adding number conversion cast (unumber) $ff in (bool~) irq::$7 ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) == (number) $ff Successful SSA optimization PassNAddNumberTypeConversions -Inlining cast (byte) memoryRemapBlock::blockPage#0 ← (unumber)(number) $40 -Inlining cast (word) memoryRemapBlock::memoryPage#0 ← (unumber)(number) $100 Inlining cast (byte) memoryRemap::remapBlocks#1 ← (unumber)(number) 0 Inlining cast (word) memoryRemap::lowerPageOffset#1 ← (unumber)(number) 0 Inlining cast (word) memoryRemap::upperPageOffset#1 ← (unumber)(number) 0 -Inlining cast *((byte*) main::mem_destroy#3) ← (unumber)(number) 0 -Inlining cast (byte) memoryRemapBlock::blockPage#1 ← (unumber)(number) $40 -Inlining cast (word) memoryRemapBlock::memoryPage#1 ← (unumber)(number) $100 +Inlining cast *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (unumber)(number) $47 +Inlining cast *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (unumber)(number) $53 +Inlining cast *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) ← (unumber)(number) 1 +Inlining cast (byte) memoryRemapBlock::blockPage#0 ← (unumber)(number) $40 +Inlining cast (word) memoryRemapBlock::memoryPage#0 ← (unumber)(number) $100 Inlining cast (byte) memoryRemap::remapBlocks#2 ← (unumber)(number) 0 Inlining cast (word) memoryRemap::lowerPageOffset#2 ← (unumber)(number) 0 Inlining cast (word) memoryRemap::upperPageOffset#2 ← (unumber)(number) 0 +Inlining cast *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (unumber)(number) $ff +Inlining cast (byte) memoryRemapBlock::blockPage#1 ← (unumber)(number) $40 +Inlining cast (word) memoryRemapBlock::memoryPage#1 ← (unumber)(number) $100 +Inlining cast (byte) memoryRemap::remapBlocks#3 ← (unumber)(number) 0 +Inlining cast (word) memoryRemap::lowerPageOffset#3 ← (unumber)(number) 0 +Inlining cast (word) memoryRemap::upperPageOffset#3 ← (unumber)(number) 0 Successful SSA optimization Pass2InlineCast Simplifying constant pointer cast (byte*) 252 Simplifying constant pointer cast (byte*) 253 Simplifying constant pointer cast (byte*) 254 Simplifying constant pointer cast (byte*) 255 +Simplifying constant pointer cast (byte*) 0 +Simplifying constant pointer cast (byte*) 1 Simplifying constant pointer cast (struct MOS6569_VICII*) 53248 +Simplifying constant pointer cast (struct MOS4569_VICIII*) 53248 +Simplifying constant pointer cast (struct MEGA65_VICIV*) 53248 +Simplifying constant pointer cast (byte*) 2048 +Simplifying constant pointer cast (struct MOS6526_CIA*) 56320 +Simplifying constant pointer cast (void()**) 65534 Simplifying constant pointer cast (byte*) 20992 Simplifying constant integer cast 3 Simplifying constant integer cast 4 @@ -595,12 +670,22 @@ Simplifying constant integer cast $f0 Simplifying constant integer cast $f Simplifying constant integer cast $20 Simplifying constant integer cast 1 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast $47 +Simplifying constant integer cast $53 +Simplifying constant integer cast $40 +Simplifying constant integer cast $40 +Simplifying constant integer cast 1 Simplifying constant integer cast $40 Simplifying constant integer cast $100 Simplifying constant integer cast 0 Simplifying constant integer cast 0 Simplifying constant integer cast 0 -Simplifying constant integer cast 0 +Simplifying constant integer cast $ff +Simplifying constant integer cast $7f +Simplifying constant integer cast $f0 Simplifying constant integer cast $ff Simplifying constant integer cast $40 Simplifying constant integer cast $100 @@ -616,12 +701,22 @@ Finalized unsigned number type (byte) $f0 Finalized unsigned number type (byte) $f Finalized unsigned number type (byte) $20 Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $47 +Finalized unsigned number type (byte) $53 +Finalized unsigned number type (byte) $40 +Finalized unsigned number type (byte) $40 +Finalized unsigned number type (byte) 1 Finalized unsigned number type (byte) $40 Finalized unsigned number type (word) $100 Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 0 -Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $ff +Finalized unsigned number type (byte) $7f +Finalized unsigned number type (byte) $f0 Finalized unsigned number type (byte) $ff Finalized unsigned number type (byte) $40 Finalized unsigned number type (word) $100 @@ -632,51 +727,42 @@ Finalized unsigned number type (byte) $ff Successful SSA optimization PassNFinalizeNumberTypeConversions Inferred type updated to byte in (unumber~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f Inferred type updated to byte in (unumber~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -Inferred type updated to byte in (unumber~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (byte) $f0 +Inferred type updated to byte in (unumber~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (byte) $f0 Inferred type updated to byte in (unumber~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f Inferred type updated to byte in (unumber~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 Inferred type updated to byte in (unumber~) memoryRemapBlock::$1 ← (byte) memoryRemapBlock::blockPage#2 / (byte) $20 Inferred type updated to byte in (unumber~) memoryRemapBlock::$2 ← (byte) 1 << (byte) memoryRemapBlock::block#0 -Inversing boolean not [52] (bool~) main::$5 ← (byte*) main::mem_destroy#1 != (const nomodify byte*) MUSIC_END from [51] (bool~) main::$4 ← (byte*) main::mem_destroy#1 == (const nomodify byte*) MUSIC_END -Successful SSA optimization Pass2UnaryNotSimplification Alias memoryRemapBlock::pageOffset#0 = memoryRemapBlock::$0 Alias memoryRemapBlock::block#0 = memoryRemapBlock::$1 Alias memoryRemapBlock::blockBits#0 = memoryRemapBlock::$2 Alias main::src#2 = main::src#3 Alias main::dst#2 = main::dst#3 -Alias main::mem_destroy#5 = main::mem_destroy#7 main::mem_destroy#8 main::mem_destroy#6 +Alias main::i#2 = main::i#3 Successful SSA optimization Pass2AliasElimination -Identical Phi Values (byte*) main::mem_destroy#4 (byte*) main::mem_destroy#5 -Successful SSA optimization Pass2IdenticalPhiElimination -Simple Condition (bool~) main::$3 [34] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 -Simple Condition (bool~) main::$5 [48] if((byte*) main::mem_destroy#1!=(const nomodify byte*) MUSIC_END) goto main::@5 -Simple Condition (bool~) main::$6 [52] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto main::@5 -Simple Condition (bool~) main::$12 [65] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto main::@7 +Simple Condition (bool~) main::$4 [45] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 +Simple Condition (bool~) main::$5 [63] if((byte) main::i#2<(byte) $f0) goto main::@6 +Simple Condition (bool~) irq::$6 [71] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto irq::@1 +Simple Condition (bool~) irq::$7 [82] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto irq::@3 Successful SSA optimization Pass2ConditionalJumpSimplification +Constant (const byte) memoryRemap::remapBlocks#1 = 0 +Constant (const word) memoryRemap::lowerPageOffset#1 = 0 +Constant (const word) memoryRemap::upperPageOffset#1 = 0 Constant (const byte) memoryRemapBlock::blockPage#0 = $40 Constant (const word) memoryRemapBlock::memoryPage#0 = $100 Constant (const byte*) main::src#0 = upperCodeData Constant (const byte*) main::dst#0 = MUSIC -Constant (const byte) memoryRemap::remapBlocks#1 = 0 -Constant (const word) memoryRemap::lowerPageOffset#1 = 0 -Constant (const word) memoryRemap::upperPageOffset#1 = 0 -Constant (const byte*) main::mem_destroy#0 = MUSIC -Constant (const byte*) main::mem_destroy#2 = MUSIC -Constant (const byte) memoryRemapBlock::blockPage#1 = $40 -Constant (const word) memoryRemapBlock::memoryPage#1 = $100 Constant (const byte) memoryRemap::remapBlocks#2 = 0 Constant (const word) memoryRemap::lowerPageOffset#2 = 0 Constant (const word) memoryRemap::upperPageOffset#2 = 0 +Constant (const byte) main::i#0 = 0 +Constant (const byte) memoryRemapBlock::blockPage#1 = $40 +Constant (const word) memoryRemapBlock::memoryPage#1 = $100 +Constant (const byte) memoryRemap::remapBlocks#3 = 0 +Constant (const word) memoryRemap::lowerPageOffset#3 = 0 +Constant (const word) memoryRemap::upperPageOffset#3 = 0 Successful SSA optimization Pass2ConstantIdentification Removing unused block main::@return Successful SSA optimization Pass2EliminateUnusedBlocks -Removing unused procedure __start -Removing unused procedure block __start -Removing unused procedure block __start::__init1 -Removing unused procedure block __start::@1 -Removing unused procedure block __start::@2 -Removing unused procedure block __start::@return -Successful SSA optimization PassNEliminateEmptyStart Rewriting division to use shift [19] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 / (byte) $20 Successful SSA optimization Pass2MultiplyToShiftRewriting Inlining constant with var siblings (const byte) memoryRemap::remapBlocks#1 @@ -685,27 +771,31 @@ Inlining constant with var siblings (const word) memoryRemap::upperPageOffset#1 Inlining constant with var siblings (const byte) memoryRemap::remapBlocks#2 Inlining constant with var siblings (const word) memoryRemap::lowerPageOffset#2 Inlining constant with var siblings (const word) memoryRemap::upperPageOffset#2 +Inlining constant with var siblings (const byte) memoryRemap::remapBlocks#3 +Inlining constant with var siblings (const word) memoryRemap::lowerPageOffset#3 +Inlining constant with var siblings (const word) memoryRemap::upperPageOffset#3 Inlining constant with var siblings (const byte) memoryRemapBlock::blockPage#0 Inlining constant with var siblings (const word) memoryRemapBlock::memoryPage#0 Inlining constant with var siblings (const byte) memoryRemapBlock::blockPage#1 Inlining constant with var siblings (const word) memoryRemapBlock::memoryPage#1 Inlining constant with var siblings (const byte*) main::src#0 Inlining constant with var siblings (const byte*) main::dst#0 -Inlining constant with var siblings (const byte*) main::mem_destroy#0 -Inlining constant with var siblings (const byte*) main::mem_destroy#2 -Constant inlined main::mem_destroy#2 = (const byte*) MUSIC +Inlining constant with var siblings (const byte) main::i#0 Constant inlined memoryRemap::remapBlocks#1 = (byte) 0 Constant inlined memoryRemapBlock::blockPage#1 = (byte) $40 Constant inlined memoryRemapBlock::blockPage#0 = (byte) $40 -Constant inlined main::mem_destroy#0 = (const byte*) MUSIC +Constant inlined memoryRemap::remapBlocks#3 = (byte) 0 +Constant inlined memoryRemap::upperPageOffset#3 = (byte) 0 Constant inlined main::src#0 = (const byte*) upperCodeData Constant inlined memoryRemap::remapBlocks#2 = (byte) 0 Constant inlined memoryRemap::upperPageOffset#1 = (byte) 0 Constant inlined memoryRemapBlock::memoryPage#1 = (word) $100 Constant inlined memoryRemap::upperPageOffset#2 = (byte) 0 Constant inlined memoryRemapBlock::memoryPage#0 = (word) $100 +Constant inlined memoryRemap::lowerPageOffset#3 = (byte) 0 Constant inlined memoryRemap::lowerPageOffset#2 = (byte) 0 Constant inlined memoryRemap::lowerPageOffset#1 = (byte) 0 +Constant inlined main::i#0 = (byte) 0 Constant inlined main::dst#0 = (const byte*) MUSIC Successful SSA optimization Pass2ConstantInlining Identical Phi Values (word) memoryRemapBlock::memoryPage#2 (word) $100 @@ -734,118 +824,160 @@ Successful SSA optimization Pass2ConstantIdentification Inlining constant with var siblings (const byte) memoryRemap::remapBlocks#0 Constant inlined memoryRemap::remapBlocks#0 = (const byte) memoryRemapBlock::blockBits#0 Successful SSA optimization Pass2ConstantInlining -Added new block during phi lifting main::@13(between main::@7 and main::@4) -Added new block during phi lifting main::@14(between main::@4 and main::@5) -Added new block during phi lifting main::@15(between main::@5 and main::@5) -Adding NOP phi() at start of main::@9 -Adding NOP phi() at start of main::@10 +Adding NOP phi() at start of __start +Adding NOP phi() at start of __start::@1 +Adding NOP phi() at start of __start::@2 +Adding NOP phi() at start of irq::@6 Adding NOP phi() at start of main::@8 +Adding NOP phi() at start of main::@4 Adding NOP phi() at start of memoryRemapBlock Adding NOP phi() at start of memoryRemapBlock::@1 CALL GRAPH -Calls in [main] to memoryRemapBlock:1 memoryRemap:6 memoryRemapBlock:16 memoryRemap:18 -Calls in [memoryRemapBlock] to memoryRemap:30 +Calls in [__start] to main:3 +Calls in [irq] to memoryRemapBlock:11 memoryRemap:13 +Calls in [main] to memoryRemap:19 memoryRemapBlock:27 memoryRemap:32 +Calls in [memoryRemapBlock] to memoryRemap:51 -Created 7 initial phi equivalence classes -Coalesced [21] main::mem_destroy#9 ← main::mem_destroy#5 -Coalesced (already) [22] main::mem_destroy#11 ← main::mem_destroy#5 -Coalesced [23] main::mem_destroy#10 ← main::mem_destroy#1 -Coalesced [27] main::dst#4 ← main::dst#1 -Coalesced [28] main::src#4 ← main::src#1 +Created 6 initial phi equivalence classes +Coalesced [44] main::i#4 ← main::i#1 +Coalesced [48] main::dst#4 ← main::dst#1 +Coalesced [49] main::src#4 ← main::src#1 Coalesced down to 6 phi equivalence classes -Culled Empty Block (label) main::@9 -Culled Empty Block (label) main::@10 +Culled Empty Block (label) __start::@2 +Culled Empty Block (label) irq::@6 Culled Empty Block (label) main::@8 -Culled Empty Block (label) main::@13 -Culled Empty Block (label) main::@15 +Culled Empty Block (label) main::@4 Culled Empty Block (label) memoryRemapBlock::@1 -Renumbering block main::@11 to main::@8 -Renumbering block main::@12 to main::@9 -Renumbering block main::@14 to main::@10 -Adding NOP phi() at start of main::@10 +Renumbering block main::@5 to main::@4 +Renumbering block main::@6 to main::@5 +Renumbering block main::@7 to main::@6 +Renumbering block main::@9 to main::@7 +Adding NOP phi() at start of __start +Adding NOP phi() at start of __start::@1 Adding NOP phi() at start of memoryRemapBlock FINAL CONTROL FLOW GRAPH +(void()) __start() +__start: scope:[__start] from + [0] phi() + to:__start::__init1 +__start::__init1: scope:[__start] from __start + [1] (volatile byte) mem_destroy_i ← (byte) 0 + to:__start::@1 +__start::@1: scope:[__start] from __start::__init1 + [2] phi() + [3] call main + to:__start::@return +__start::@return: scope:[__start] from __start::@1 + [4] return + to:@return + +interrupt(HARDWARE_STACK)(void()) irq() +irq: scope:[irq] from + [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER + [6] *((const byte*) MUSIC + (volatile byte) mem_destroy_i) ← ++ *((const byte*) MUSIC + (volatile byte) mem_destroy_i) + [7] (volatile byte) mem_destroy_i ← ++ (volatile byte) mem_destroy_i + to:irq::@1 +irq::@1: scope:[irq] from irq irq::@1 + [8] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto irq::@1 + to:irq::@2 +irq::@2: scope:[irq] from irq::@1 + [9] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) + [10] call memoryRemapBlock + to:irq::@5 +irq::@5: scope:[irq] from irq::@2 + [11] call *((const void()*) musicPlay) + [12] call memoryRemap + to:irq::@3 +irq::@3: scope:[irq] from irq::@3 irq::@5 + [13] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto irq::@3 + to:irq::@4 +irq::@4: scope:[irq] from irq::@3 + [14] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) + to:irq::@return +irq::@return: scope:[irq] from irq::@4 + [15] return + to:@return + (void()) main() -main: scope:[main] from +main: scope:[main] from __start::@1 asm { sei } - [1] call memoryRemapBlock + [17] call memoryRemap + to:main::@6 +main::@6: scope:[main] from main + [18] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $47 + [19] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $53 + [20] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | (byte) $40 + [21] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | (byte) $40 + [22] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK + [23] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO + [24] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) ← (byte) 1 + [25] call memoryRemapBlock to:main::@1 -main::@1: scope:[main] from main main::@2 - [2] (byte*) main::src#2 ← phi( main::@2/(byte*) main::src#1 main/(const byte*) upperCodeData ) - [2] (byte*) main::dst#2 ← phi( main::@2/(byte*) main::dst#1 main/(const byte*) MUSIC ) - [3] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 +main::@1: scope:[main] from main::@2 main::@6 + [26] (byte*) main::src#2 ← phi( main::@2/(byte*) main::src#1 main::@6/(const byte*) upperCodeData ) + [26] (byte*) main::dst#2 ← phi( main::@2/(byte*) main::dst#1 main::@6/(const byte*) MUSIC ) + [27] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 to:main::@3 main::@3: scope:[main] from main::@1 - [4] call *((const void()*) musicInit) - [5] call memoryRemap - to:main::@4 -main::@4: scope:[main] from main::@3 main::@7 - [6] (byte*) main::mem_destroy#3 ← phi( main::@3/(const byte*) MUSIC main::@7/(byte*) main::mem_destroy#5 ) - [7] *((byte*) main::mem_destroy#3) ← (byte) 0 - [8] (byte*) main::mem_destroy#1 ← ++ (byte*) main::mem_destroy#3 - [9] if((byte*) main::mem_destroy#1!=(const nomodify byte*) MUSIC_END) goto main::@10 - to:main::@5 -main::@10: scope:[main] from main::@4 - [10] phi() - to:main::@5 -main::@5: scope:[main] from main::@10 main::@4 main::@5 - [11] (byte*) main::mem_destroy#5 ← phi( main::@10/(byte*) main::mem_destroy#1 main::@5/(byte*) main::mem_destroy#5 main::@4/(const byte*) MUSIC ) - [12] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto main::@5 - to:main::@6 -main::@6: scope:[main] from main::@5 - [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) - [14] call memoryRemapBlock - to:main::@8 -main::@8: scope:[main] from main::@6 - [15] call *((const void()*) musicPlay) - [16] call memoryRemap - to:main::@9 -main::@9: scope:[main] from main::@8 - [17] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) + [28] call *((const void()*) musicInit) + [29] call memoryRemap to:main::@7 -main::@7: scope:[main] from main::@7 main::@9 - [18] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto main::@7 +main::@7: scope:[main] from main::@3 + [30] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1+(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR + [31] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (byte) $ff + [32] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & (byte) $7f + [33] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER + [34] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_STACK)(void()) irq() + asm { cli } + to:main::@4 +main::@4: scope:[main] from main::@4 main::@5 main::@7 + [36] (byte) main::i#2 ← phi( main::@4/(byte) 0 main::@5/(byte) main::i#1 ) + [37] if((byte) main::i#2<(byte) $f0) goto main::@5 + to:main::@4 +main::@5: scope:[main] from main::@4 + [38] *((const nomodify byte*) DEFAULT_SCREEN + (byte) main::i#2) ← *((const byte*) MUSIC + (byte) main::i#2) + [39] (byte) main::i#1 ← ++ (byte) main::i#2 to:main::@4 main::@2: scope:[main] from main::@1 - [19] *((byte*) main::dst#2) ← *((byte*) main::src#2) - [20] (byte*) main::dst#1 ← ++ (byte*) main::dst#2 - [21] (byte*) main::src#1 ← ++ (byte*) main::src#2 + [40] *((byte*) main::dst#2) ← *((byte*) main::src#2) + [41] (byte*) main::dst#1 ← ++ (byte*) main::dst#2 + [42] (byte*) main::src#1 ← ++ (byte*) main::src#2 to:main::@1 (void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) -memoryRemapBlock: scope:[memoryRemapBlock] from main main::@6 - [22] phi() - [23] call memoryRemap +memoryRemapBlock: scope:[memoryRemapBlock] from irq::@2 main::@6 + [43] phi() + [44] call memoryRemap to:memoryRemapBlock::@return memoryRemapBlock::@return: scope:[memoryRemapBlock] from memoryRemapBlock - [24] return + [45] return to:@return (void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerPageOffset , (word) memoryRemap::upperPageOffset) -memoryRemap: scope:[memoryRemap] from main::@3 main::@8 memoryRemapBlock - [25] (word) memoryRemap::upperPageOffset#3 ← phi( main::@8/(byte) 0 main::@3/(byte) 0 memoryRemapBlock/(const word) memoryRemapBlock::pageOffset#0 ) - [25] (byte) memoryRemap::remapBlocks#3 ← phi( main::@8/(byte) 0 main::@3/(byte) 0 memoryRemapBlock/(const byte) memoryRemapBlock::blockBits#0 ) - [25] (word) memoryRemap::lowerPageOffset#3 ← phi( main::@8/(byte) 0 main::@3/(byte) 0 memoryRemapBlock/(const word) memoryRemapBlock::pageOffset#0 ) - [26] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#3 - [27] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 - [28] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#3 << (byte) 4 - [29] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#3 - [30] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f - [31] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 - [32] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 - [33] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#3 - [34] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 - [35] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (byte) $f0 - [36] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#3 - [37] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f - [38] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 - [39] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 +memoryRemap: scope:[memoryRemap] from irq::@5 main main::@3 memoryRemapBlock + [46] (word) memoryRemap::upperPageOffset#4 ← phi( irq::@5/(byte) 0 main/(byte) 0 main::@3/(byte) 0 memoryRemapBlock/(const word) memoryRemapBlock::pageOffset#0 ) + [46] (byte) memoryRemap::remapBlocks#4 ← phi( irq::@5/(byte) 0 main/(byte) 0 main::@3/(byte) 0 memoryRemapBlock/(const byte) memoryRemapBlock::blockBits#0 ) + [46] (word) memoryRemap::lowerPageOffset#4 ← phi( irq::@5/(byte) 0 main/(byte) 0 main::@3/(byte) 0 memoryRemapBlock/(const word) memoryRemapBlock::pageOffset#0 ) + [47] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#4 + [48] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 + [49] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#4 << (byte) 4 + [50] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#4 + [51] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f + [52] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 + [53] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 + [54] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#4 + [55] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 + [56] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (byte) $f0 + [57] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#4 + [58] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f + [59] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 + [60] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } to:memoryRemap::@return memoryRemap::@return: scope:[memoryRemap] from memoryRemap - [41] return + [62] return to:@return @@ -1134,17 +1266,19 @@ VARIABLE REGISTER WEIGHTS (byte) MOS6581_SID::POT_X (byte) MOS6581_SID::POT_Y (byte) MOS6581_SID::VOLUME_FILTER_MODE +(void()) __start() +interrupt(HARDWARE_STACK)(void()) irq() (void()) main() (byte*) main::dst -(byte*) main::dst#1 11.0 -(byte*) main::dst#2 14.666666666666666 -(byte*) main::mem_destroy -(byte*) main::mem_destroy#1 11.0 -(byte*) main::mem_destroy#3 61.5 -(byte*) main::mem_destroy#5 39.25 +(byte*) main::dst#1 101.0 +(byte*) main::dst#2 134.66666666666666 +(byte) main::i +(byte) main::i#1 202.0 +(byte) main::i#2 468.3333333333334 (byte*) main::src -(byte*) main::src#1 22.0 -(byte*) main::src#2 8.25 +(byte*) main::src#1 202.0 +(byte*) main::src#2 75.75 +(volatile byte) mem_destroy_i loadstore 5.0 (void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerPageOffset , (word) memoryRemap::upperPageOffset) (byte~) memoryRemap::$0 2002.0 (byte~) memoryRemap::$1 667.3333333333334 @@ -1157,11 +1291,11 @@ VARIABLE REGISTER WEIGHTS (byte~) memoryRemap::$8 2002.0 (byte~) memoryRemap::$9 2002.0 (word) memoryRemap::lowerPageOffset -(word) memoryRemap::lowerPageOffset#3 500.5 +(word) memoryRemap::lowerPageOffset#4 500.5 (byte) memoryRemap::remapBlocks -(byte) memoryRemap::remapBlocks#3 200.2 +(byte) memoryRemap::remapBlocks#4 200.2 (word) memoryRemap::upperPageOffset -(word) memoryRemap::upperPageOffset#3 182.0 +(word) memoryRemap::upperPageOffset#4 182.0 (void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) (byte) memoryRemapBlock::block (byte) memoryRemapBlock::blockBits @@ -1172,10 +1306,11 @@ VARIABLE REGISTER WEIGHTS Initial phi equivalence classes [ main::dst#2 main::dst#1 ] [ main::src#2 main::src#1 ] -[ main::mem_destroy#3 main::mem_destroy#5 main::mem_destroy#1 ] -[ memoryRemap::lowerPageOffset#3 ] -[ memoryRemap::remapBlocks#3 ] -[ memoryRemap::upperPageOffset#3 ] +[ main::i#2 main::i#1 ] +[ memoryRemap::lowerPageOffset#4 ] +[ memoryRemap::remapBlocks#4 ] +[ memoryRemap::upperPageOffset#4 ] +Added variable mem_destroy_i to live range equivalence class [ mem_destroy_i ] Added variable memoryRemap::$0 to live range equivalence class [ memoryRemap::$0 ] Added variable memoryRemap::$1 to live range equivalence class [ memoryRemap::$1 ] Added variable memoryRemap::$2 to live range equivalence class [ memoryRemap::$2 ] @@ -1189,10 +1324,11 @@ Added variable memoryRemap::$9 to live range equivalence class [ memoryRemap::$9 Complete equivalence classes [ main::dst#2 main::dst#1 ] [ main::src#2 main::src#1 ] -[ main::mem_destroy#3 main::mem_destroy#5 main::mem_destroy#1 ] -[ memoryRemap::lowerPageOffset#3 ] -[ memoryRemap::remapBlocks#3 ] -[ memoryRemap::upperPageOffset#3 ] +[ main::i#2 main::i#1 ] +[ memoryRemap::lowerPageOffset#4 ] +[ memoryRemap::remapBlocks#4 ] +[ memoryRemap::upperPageOffset#4 ] +[ mem_destroy_i ] [ memoryRemap::$0 ] [ memoryRemap::$1 ] [ memoryRemap::$2 ] @@ -1205,10 +1341,11 @@ Complete equivalence classes [ memoryRemap::$9 ] Allocated zp[2]:2 [ main::dst#2 main::dst#1 ] Allocated zp[2]:4 [ main::src#2 main::src#1 ] -Allocated zp[2]:6 [ main::mem_destroy#3 main::mem_destroy#5 main::mem_destroy#1 ] -Allocated zp[2]:8 [ memoryRemap::lowerPageOffset#3 ] -Allocated zp[1]:10 [ memoryRemap::remapBlocks#3 ] -Allocated zp[2]:11 [ memoryRemap::upperPageOffset#3 ] +Allocated zp[1]:6 [ main::i#2 main::i#1 ] +Allocated zp[2]:7 [ memoryRemap::lowerPageOffset#4 ] +Allocated zp[1]:9 [ memoryRemap::remapBlocks#4 ] +Allocated zp[2]:10 [ memoryRemap::upperPageOffset#4 ] +Allocated zp[1]:12 [ mem_destroy_i ] Allocated zp[1]:13 [ memoryRemap::$0 ] Allocated zp[1]:14 [ memoryRemap::$1 ] Allocated zp[1]:15 [ memoryRemap::$2 ] @@ -1223,7 +1360,7 @@ Allocated zp[1]:22 [ memoryRemap::$9 ] INITIAL ASM Target platform is mega65 / MEGA45GS02 // File Comments -// SID music located in another bank being played using memory mapping on MEGA65 +// SID music located in another bank being played in a raster IRQ using memory mapping on the MEGA65 // Music is Cybernoid II by Jeroen Tel released in 1988 by Hewson https://csdb.dk/sid/?id=28140 // SID relocated using http://www.linusakesson.net/software/sidreloc/index.php // Upstart @@ -1240,42 +1377,226 @@ Target platform is mega65 / MEGA45GS02 .segment Basic .byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0 .byte $15, $20, $14, $00, $9e, $20 // 20 SYS -.text toIntString(main) // NNNN +.text toIntString(__start) // NNNN .byte $00, $00, $00 // // Global Constants & labels + // Value that disables all CIA interrupts when stored to the CIA Interrupt registers + .const CIA_INTERRUPT_CLEAR = $7f + // Bits for the VICII IRQ Status/Enable Registers + .const IRQ_RASTER = 1 + // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written + .const PROCPORT_DDR_MEMORY_MASK = 7 + // RAM in 0xA000, 0xE000 I/O in 0xD000 + .const PROCPORT_RAM_IO = 5 + .const OFFSET_STRUCT_MOS4569_VICIII_KEY = $2f + .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLB = $31 + .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLC = $54 + .const OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO = $5c + .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12 + .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11 + .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a + .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19 .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 + // Processor port data direction register + .label PROCPORT_DDR = 0 + // Processor Port Register controlling RAM/ROM configuration and the datasette + .label PROCPORT = 1 // The VIC-II MOS 6567/6569 .label VICII = $d000 + // The VIC III MOS 4567/4569 + .label VICIII = $d000 + // The VIC IV + .label VICIV = $d000 + // Default address of screen character matrix + .label DEFAULT_SCREEN = $800 + // The CIA#1: keyboard matrix, joystick #1/#2 + .label CIA1 = $dc00 + // The vector used when the HARDWARE serves IRQ interrupts + .label HARDWARE_IRQ = $fffe // Address after the end of the music .label MUSIC_END = $5200 // Pointer to the music init routine .label musicInit = MUSIC // Pointer to the music play routine .label musicPlay = MUSIC+3 + // Index used to destroy unmapped music memory (to demonstrate that mapping works) + .label mem_destroy_i = $c .segment Code + // __start +__start: { + jmp __init1 + // __start::__init1 + __init1: + // [1] (volatile byte) mem_destroy_i ← (byte) 0 -- vbuz1=vbuc1 + lda #0 + sta.z mem_destroy_i + // [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1] + __b1_from___init1: + jmp __b1 + // __start::@1 + __b1: + // [3] call main + jsr main + jmp __breturn + // __start::@return + __breturn: + // [4] return + rts +} + // irq +// Raster IRQ routine +irq: { + // entry interrupt(HARDWARE_STACK) + pha + txa + pha + tya + pha + // [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 + // Acknowledge the IRQ + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS + // [6] *((const byte*) MUSIC + (volatile byte) mem_destroy_i) ← ++ *((const byte*) MUSIC + (volatile byte) mem_destroy_i) -- pbuc1_derefidx_vbuz1=_inc_pbuc1_derefidx_vbuz1 + ldx.z mem_destroy_i + inc MUSIC,x + // [7] (volatile byte) mem_destroy_i ← ++ (volatile byte) mem_destroy_i -- vbuz1=_inc_vbuz1 + inc.z mem_destroy_i + jmp __b1 + // Wait for the raster + // irq::@1 + __b1: + // [8] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto irq::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 + lda #$ff + cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + bne __b1 + jmp __b2 + // irq::@2 + __b2: + // [9] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1 + inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + // [10] call memoryRemapBlock + // Remap memory to put music at $4000 + // [43] phi from irq::@2 to memoryRemapBlock [phi:irq::@2->memoryRemapBlock] + memoryRemapBlock_from___b2: + jsr memoryRemapBlock + jmp __b5 + // irq::@5 + __b5: + // [11] call *((const void()*) musicPlay) + // Play remapped SID + jsr musicPlay + // [12] call memoryRemap + // Reset memory mapping + // [46] phi from irq::@5 to memoryRemap [phi:irq::@5->memoryRemap] + memoryRemap_from___b5: + // [46] phi (word) memoryRemap::upperPageOffset#4 = (byte) 0 [phi:irq::@5->memoryRemap#0] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.upperPageOffset + lda #>0 + sta.z memoryRemap.upperPageOffset+1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (byte) 0 [phi:irq::@5->memoryRemap#1] -- vbuz1=vbuc1 + lda #0 + sta.z memoryRemap.remapBlocks + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (byte) 0 [phi:irq::@5->memoryRemap#2] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.lowerPageOffset + lda #>0 + sta.z memoryRemap.lowerPageOffset+1 + jsr memoryRemap + jmp __b3 + // Wait for the raster + // irq::@3 + __b3: + // [13] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto irq::@3 -- _deref_pbuc1_eq_vbuc2_then_la1 + lda #$ff + cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + beq __b3 + jmp __b4 + // irq::@4 + __b4: + // [14] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1 + dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + jmp __breturn + // irq::@return + __breturn: + // [15] return - exit interrupt(HARDWARE_STACK) + pla + tay + pla + tax + pla + rti +} // main main: { .label dst = 2 .label src = 4 - // Pointer to (unmapped) $4000 used for overwriting to demonstrate the mapping works - .label mem_destroy = 6 + .label i = 6 // asm { sei } // Stop IRQ's sei - // [1] call memoryRemapBlock + // [17] call memoryRemap + // Map memory to BANK 0 : 0x00XXXX - giving access to I/O + // [46] phi from main to memoryRemap [phi:main->memoryRemap] + memoryRemap_from_main: + // [46] phi (word) memoryRemap::upperPageOffset#4 = (byte) 0 [phi:main->memoryRemap#0] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.upperPageOffset + lda #>0 + sta.z memoryRemap.upperPageOffset+1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (byte) 0 [phi:main->memoryRemap#1] -- vbuz1=vbuc1 + lda #0 + sta.z memoryRemap.remapBlocks + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (byte) 0 [phi:main->memoryRemap#2] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.lowerPageOffset + lda #>0 + sta.z memoryRemap.lowerPageOffset+1 + jsr memoryRemap + jmp __b6 + // main::@6 + __b6: + // [18] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $47 -- _deref_pbuc1=vbuc2 + // Enable MEGA65 features + lda #$47 + sta VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY + // [19] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $53 -- _deref_pbuc1=vbuc2 + lda #$53 + sta VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY + // [20] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | (byte) $40 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2 + // Enable 48MHz fast mode + lda #$40 + ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB + // [21] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | (byte) $40 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2 + lda #$40 + ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC + // [22] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK -- _deref_pbuc1=vbuc2 + // no kernal or BASIC rom visible + lda #PROCPORT_DDR_MEMORY_MASK + sta PROCPORT_DDR + // [23] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO -- _deref_pbuc1=vbuc2 + lda #PROCPORT_RAM_IO + sta PROCPORT + // [24] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) ← (byte) 1 -- _deref_pbuc1=vbuc2 + // open sideborder + lda #1 + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO + // [25] call memoryRemapBlock // Remap [$4000-$5fff] to point to [$10000-$11fff] - // [22] phi from main to memoryRemapBlock [phi:main->memoryRemapBlock] - memoryRemapBlock_from_main: + // [43] phi from main::@6 to memoryRemapBlock [phi:main::@6->memoryRemapBlock] + memoryRemapBlock_from___b6: jsr memoryRemapBlock - // [2] phi from main to main::@1 [phi:main->main::@1] - __b1_from_main: - // [2] phi (byte*) main::src#2 = (const byte*) upperCodeData [phi:main->main::@1#0] -- pbuz1=pbuc1 + // [26] phi from main::@6 to main::@1 [phi:main::@6->main::@1] + __b1_from___b6: + // [26] phi (byte*) main::src#2 = (const byte*) upperCodeData [phi:main::@6->main::@1#0] -- pbuz1=pbuc1 lda #upperCodeData sta.z src+1 - // [2] phi (byte*) main::dst#2 = (const byte*) MUSIC [phi:main->main::@1#1] -- pbuz1=pbuc1 + // [26] phi (byte*) main::dst#2 = (const byte*) MUSIC [phi:main::@6->main::@1#1] -- pbuz1=pbuc1 lda #MUSIC @@ -1284,7 +1605,7 @@ main: { // Transfer banked code/data to upper memory ($11000) // main::@1 __b1: - // [3] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 -- pbuz1_lt_pbuc1_then_la1 + // [27] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 -- pbuz1_lt_pbuc1_then_la1 lda.z dst+1 cmp #>MUSIC_END bcc __b2 @@ -1296,142 +1617,98 @@ main: { jmp __b3 // main::@3 __b3: - // [4] call *((const void()*) musicInit) + // [28] call *((const void()*) musicInit) // Initialize SID memory is still remapped) jsr musicInit - // [5] call memoryRemap + // [29] call memoryRemap // Reset memory mapping - // [25] phi from main::@3 to memoryRemap [phi:main::@3->memoryRemap] + // [46] phi from main::@3 to memoryRemap [phi:main::@3->memoryRemap] memoryRemap_from___b3: - // [25] phi (word) memoryRemap::upperPageOffset#3 = (byte) 0 [phi:main::@3->memoryRemap#0] -- vwuz1=vbuc1 + // [46] phi (word) memoryRemap::upperPageOffset#4 = (byte) 0 [phi:main::@3->memoryRemap#0] -- vwuz1=vbuc1 lda #<0 sta.z memoryRemap.upperPageOffset lda #>0 sta.z memoryRemap.upperPageOffset+1 - // [25] phi (byte) memoryRemap::remapBlocks#3 = (byte) 0 [phi:main::@3->memoryRemap#1] -- vbuz1=vbuc1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (byte) 0 [phi:main::@3->memoryRemap#1] -- vbuz1=vbuc1 lda #0 sta.z memoryRemap.remapBlocks - // [25] phi (word) memoryRemap::lowerPageOffset#3 = (byte) 0 [phi:main::@3->memoryRemap#2] -- vwuz1=vbuc1 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (byte) 0 [phi:main::@3->memoryRemap#2] -- vwuz1=vbuc1 lda #<0 sta.z memoryRemap.lowerPageOffset lda #>0 sta.z memoryRemap.lowerPageOffset+1 jsr memoryRemap - // [6] phi from main::@3 to main::@4 [phi:main::@3->main::@4] - __b4_from___b3: - // [6] phi (byte*) main::mem_destroy#3 = (const byte*) MUSIC [phi:main::@3->main::@4#0] -- pbuz1=pbuc1 - lda #MUSIC - sta.z mem_destroy+1 + jmp __b7 + // main::@7 + __b7: + // [30] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1+(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 + // Set up raster interrupts C64 style + // Disable CIA 1 Timer IRQ + lda #CIA_INTERRUPT_CLEAR + sta CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT + // [31] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (byte) $ff -- _deref_pbuc1=vbuc2 + // Set raster line to 0xff + lda #$ff + sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + // [32] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 + lda #$7f + and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + // [33] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 + // Enable Raster Interrupt + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE + // [34] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_STACK)(void()) irq() -- _deref_qprc1=pprc2 + // Set the IRQ routine + lda #irq + sta HARDWARE_IRQ+1 + // asm { cli } + // Enable IRQ + cli + // [36] phi from main::@7 to main::@4 [phi:main::@7->main::@4] + __b4_from___b7: jmp __b4 // main::@4 __b4: - // [7] *((byte*) main::mem_destroy#3) ← (byte) 0 -- _deref_pbuz1=vbuc1 - // Overwrite data in the unmapped memory where the music is mapped in (to demonstrate that mapping works) + // [37] if((byte) main::i#2<(byte) $f0) goto main::@5 -- vbuz1_lt_vbuc1_then_la1 + lda.z i + cmp #$f0 + bcc __b5 + // [36] phi from main::@4 to main::@4 [phi:main::@4->main::@4] + __b4_from___b4: + // [36] phi (byte) main::i#2 = (byte) 0 [phi:main::@4->main::@4#0] -- vbuz1=vbuc1 lda #0 - ldy #0 - sta (mem_destroy),y - // [8] (byte*) main::mem_destroy#1 ← ++ (byte*) main::mem_destroy#3 -- pbuz1=_inc_pbuz1 - inw.z mem_destroy - // [9] if((byte*) main::mem_destroy#1!=(const nomodify byte*) MUSIC_END) goto main::@10 -- pbuz1_neq_pbuc1_then_la1 - lda.z mem_destroy+1 - cmp #>MUSIC_END - bne __b10_from___b4 - lda.z mem_destroy - cmp #main::@5] - __b5_from___b4: - // [11] phi (byte*) main::mem_destroy#5 = (const byte*) MUSIC [phi:main::@4->main::@5#0] -- pbuz1=pbuc1 - lda #MUSIC - sta.z mem_destroy+1 - jmp __b5 - // [10] phi from main::@4 to main::@10 [phi:main::@4->main::@10] - __b10_from___b4: - jmp __b10 - // main::@10 - __b10: - // [11] phi from main::@10 main::@5 to main::@5 [phi:main::@10/main::@5->main::@5] - __b5_from___b10: - __b5_from___b5: - // [11] phi (byte*) main::mem_destroy#5 = (byte*) main::mem_destroy#1 [phi:main::@10/main::@5->main::@5#0] -- register_copy - jmp __b5 - // Wait for the raster + sta.z i + jmp __b4 // main::@5 __b5: - // [12] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto main::@5 -- _deref_pbuc1_neq_vbuc2_then_la1 - lda #$ff - cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER - bne __b5_from___b5 - jmp __b6 - // main::@6 - __b6: - // [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1 - inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - // [14] call memoryRemapBlock - // Remap memory to put music at $4000 - // [22] phi from main::@6 to memoryRemapBlock [phi:main::@6->memoryRemapBlock] - memoryRemapBlock_from___b6: - jsr memoryRemapBlock - jmp __b8 - // main::@8 - __b8: - // [15] call *((const void()*) musicPlay) - // Play remapped SID - jsr musicPlay - // [16] call memoryRemap - // Reset memory mapping - // [25] phi from main::@8 to memoryRemap [phi:main::@8->memoryRemap] - memoryRemap_from___b8: - // [25] phi (word) memoryRemap::upperPageOffset#3 = (byte) 0 [phi:main::@8->memoryRemap#0] -- vwuz1=vbuc1 - lda #<0 - sta.z memoryRemap.upperPageOffset - lda #>0 - sta.z memoryRemap.upperPageOffset+1 - // [25] phi (byte) memoryRemap::remapBlocks#3 = (byte) 0 [phi:main::@8->memoryRemap#1] -- vbuz1=vbuc1 - lda #0 - sta.z memoryRemap.remapBlocks - // [25] phi (word) memoryRemap::lowerPageOffset#3 = (byte) 0 [phi:main::@8->memoryRemap#2] -- vwuz1=vbuc1 - lda #<0 - sta.z memoryRemap.lowerPageOffset - lda #>0 - sta.z memoryRemap.lowerPageOffset+1 - jsr memoryRemap - jmp __b9 - // main::@9 - __b9: - // [17] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1 - dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - jmp __b7 - // Wait for the raster - // main::@7 - __b7: - // [18] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto main::@7 -- _deref_pbuc1_eq_vbuc2_then_la1 - lda #$ff - cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER - beq __b7 - // [6] phi from main::@7 to main::@4 [phi:main::@7->main::@4] - __b4_from___b7: - // [6] phi (byte*) main::mem_destroy#3 = (byte*) main::mem_destroy#5 [phi:main::@7->main::@4#0] -- register_copy + // [38] *((const nomodify byte*) DEFAULT_SCREEN + (byte) main::i#2) ← *((const byte*) MUSIC + (byte) main::i#2) -- pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 + ldy.z i + lda MUSIC,y + sta DEFAULT_SCREEN,y + // [39] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 + inc.z i + // [36] phi from main::@5 to main::@4 [phi:main::@5->main::@4] + __b4_from___b5: + // [36] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@4#0] -- register_copy jmp __b4 // main::@2 __b2: - // [19] *((byte*) main::dst#2) ← *((byte*) main::src#2) -- _deref_pbuz1=_deref_pbuz2 + // [40] *((byte*) main::dst#2) ← *((byte*) main::src#2) -- _deref_pbuz1=_deref_pbuz2 ldy #0 lda (src),y ldy #0 sta (dst),y - // [20] (byte*) main::dst#1 ← ++ (byte*) main::dst#2 -- pbuz1=_inc_pbuz1 + // [41] (byte*) main::dst#1 ← ++ (byte*) main::dst#2 -- pbuz1=_inc_pbuz1 inw.z dst - // [21] (byte*) main::src#1 ← ++ (byte*) main::src#2 -- pbuz1=_inc_pbuz1 + // [42] (byte*) main::src#1 ← ++ (byte*) main::src#2 -- pbuz1=_inc_pbuz1 inw.z src - // [2] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + // [26] phi from main::@2 to main::@1 [phi:main::@2->main::@1] __b1_from___b2: - // [2] phi (byte*) main::src#2 = (byte*) main::src#1 [phi:main::@2->main::@1#0] -- register_copy - // [2] phi (byte*) main::dst#2 = (byte*) main::dst#1 [phi:main::@2->main::@1#1] -- register_copy + // [26] phi (byte*) main::src#2 = (byte*) main::src#1 [phi:main::@2->main::@1#0] -- register_copy + // [26] phi (byte*) main::dst#2 = (byte*) main::dst#1 [phi:main::@2->main::@1#1] -- register_copy jmp __b1 } // memoryRemapBlock @@ -1444,18 +1721,18 @@ memoryRemapBlock: { .const pageOffset = $100-$40 .const block = $40>>5 .const blockBits = 1<memoryRemap] + // [44] call memoryRemap + // [46] phi from memoryRemapBlock to memoryRemap [phi:memoryRemapBlock->memoryRemap] memoryRemap_from_memoryRemapBlock: - // [25] phi (word) memoryRemap::upperPageOffset#3 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#0] -- vwuz1=vwuc1 + // [46] phi (word) memoryRemap::upperPageOffset#4 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#0] -- vwuz1=vwuc1 lda #pageOffset sta.z memoryRemap.upperPageOffset+1 - // [25] phi (byte) memoryRemap::remapBlocks#3 = (const byte) memoryRemapBlock::blockBits#0 [phi:memoryRemapBlock->memoryRemap#1] -- vbuz1=vbuc1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (const byte) memoryRemapBlock::blockBits#0 [phi:memoryRemapBlock->memoryRemap#1] -- vbuz1=vbuc1 lda #blockBits sta.z memoryRemap.remapBlocks - // [25] phi (word) memoryRemap::lowerPageOffset#3 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#2] -- vwuz1=vwuc1 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#2] -- vwuz1=vwuc1 lda #pageOffset @@ -1464,7 +1741,7 @@ memoryRemapBlock: { jmp __breturn // memoryRemapBlock::@return __breturn: - // [24] return + // [45] return rts } // memoryRemap @@ -1492,7 +1769,7 @@ memoryRemapBlock: { // - If block 5 ($a000-$bfff) is remapped it will point to upperPageOffset*$100 + $a000. // - If block 6 ($c000-$dfff) is remapped it will point to upperPageOffset*$100 + $c000. // - If block 7 ($e000-$ffff) is remapped it will point to upperPageOffset*$100 + $e000. -// memoryRemap(byte zp($a) remapBlocks, word zp(8) lowerPageOffset, word zp($b) upperPageOffset) +// memoryRemap(byte zp(9) remapBlocks, word zp(7) lowerPageOffset, word zp($a) upperPageOffset) memoryRemap: { .label aVal = $fc .label xVal = $fd @@ -1508,58 +1785,58 @@ memoryRemap: { .label __7 = $14 .label __8 = $15 .label __9 = $16 - .label lowerPageOffset = 8 - .label remapBlocks = $a - .label upperPageOffset = $b - // [26] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#3 -- vbuz1=_lo_vwuz2 + .label lowerPageOffset = 7 + .label remapBlocks = 9 + .label upperPageOffset = $a + // [47] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#4 -- vbuz1=_lo_vwuz2 lda.z lowerPageOffset sta.z __0 - // [27] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 -- _deref_pbuc1=vbuz1 + // [48] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 -- _deref_pbuc1=vbuz1 lda.z __0 sta aVal - // [28] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#3 << (byte) 4 -- vbuz1=vbuz2_rol_4 + // [49] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#4 << (byte) 4 -- vbuz1=vbuz2_rol_4 lda.z remapBlocks asl asl asl asl sta.z __1 - // [29] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#3 -- vbuz1=_hi_vwuz2 + // [50] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#4 -- vbuz1=_hi_vwuz2 lda.z lowerPageOffset+1 sta.z __2 - // [30] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f -- vbuz1=vbuz2_band_vbuc1 + // [51] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f -- vbuz1=vbuz2_band_vbuc1 lda #$f and.z __2 sta.z __3 - // [31] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -- vbuz1=vbuz2_bor_vbuz3 + // [52] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -- vbuz1=vbuz2_bor_vbuz3 lda.z __1 ora.z __3 sta.z __4 - // [32] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 -- _deref_pbuc1=vbuz1 + // [53] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 -- _deref_pbuc1=vbuz1 lda.z __4 sta xVal - // [33] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#3 -- vbuz1=_lo_vwuz2 + // [54] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#4 -- vbuz1=_lo_vwuz2 lda.z upperPageOffset sta.z __5 - // [34] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 -- _deref_pbuc1=vbuz1 + // [55] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 -- _deref_pbuc1=vbuz1 lda.z __5 sta yVal - // [35] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (byte) $f0 -- vbuz1=vbuz2_band_vbuc1 + // [56] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (byte) $f0 -- vbuz1=vbuz2_band_vbuc1 lda #$f0 and.z remapBlocks sta.z __6 - // [36] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#3 -- vbuz1=_hi_vwuz2 + // [57] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#4 -- vbuz1=_hi_vwuz2 lda.z upperPageOffset+1 sta.z __7 - // [37] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f -- vbuz1=vbuz2_band_vbuc1 + // [58] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f -- vbuz1=vbuz2_band_vbuc1 lda #$f and.z __7 sta.z __8 - // [38] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 -- vbuz1=vbuz2_bor_vbuz3 + // [59] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 -- vbuz1=vbuz2_bor_vbuz3 lda.z __6 ora.z __8 sta.z __9 - // [39] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 -- _deref_pbuc1=vbuz1 + // [60] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 -- _deref_pbuc1=vbuz1 lda.z __9 sta zVal // asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } @@ -1572,7 +1849,7 @@ memoryRemap: { jmp __breturn // memoryRemap::@return __breturn: - // [41] return + // [62] return rts } // File Data @@ -1590,41 +1867,73 @@ MUSIC: REGISTER UPLIFT POTENTIAL REGISTERS -Statement [3] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 [ main::dst#2 main::src#2 ] ( [ main::dst#2 main::src#2 ] { } ) always clobbers reg byte a -Statement [4] call *((const void()*) musicInit) [ ] ( [ ] { } ) always clobbers reg byte a reg byte x reg byte y reg byte z -Statement [7] *((byte*) main::mem_destroy#3) ← (byte) 0 [ main::mem_destroy#3 ] ( [ main::mem_destroy#3 ] { } ) always clobbers reg byte a reg byte y -Statement [9] if((byte*) main::mem_destroy#1!=(const nomodify byte*) MUSIC_END) goto main::@10 [ main::mem_destroy#1 ] ( [ main::mem_destroy#1 ] { } ) always clobbers reg byte a -Statement [12] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto main::@5 [ main::mem_destroy#5 ] ( [ main::mem_destroy#5 ] { } ) always clobbers reg byte a -Statement [15] call *((const void()*) musicPlay) [ main::mem_destroy#5 ] ( [ main::mem_destroy#5 ] { } ) always clobbers reg byte a reg byte x reg byte y reg byte z -Statement [18] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto main::@7 [ main::mem_destroy#5 ] ( [ main::mem_destroy#5 ] { } ) always clobbers reg byte a -Statement [19] *((byte*) main::dst#2) ← *((byte*) main::src#2) [ main::dst#2 main::src#2 ] ( [ main::dst#2 main::src#2 ] { } ) always clobbers reg byte a reg byte y -Statement [28] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#3 << (byte) 4 [ memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] ( memoryRemap:5 [ memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] { } memoryRemap:16 [ main::mem_destroy#5 memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] { } memoryRemapBlock:1::memoryRemap:23 [ memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] { } memoryRemapBlock:14::memoryRemap:23 [ main::mem_destroy#5 memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] { } ) always clobbers reg byte a -Removing always clobbered register reg byte a as potential for zp[1]:10 [ memoryRemap::remapBlocks#3 ] -Statement [30] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f [ memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] ( memoryRemap:5 [ memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemap:16 [ main::mem_destroy#5 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemapBlock:1::memoryRemap:23 [ memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemapBlock:14::memoryRemap:23 [ main::mem_destroy#5 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] { } ) always clobbers reg byte a +Statement [1] (volatile byte) mem_destroy_i ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER [ mem_destroy_i ] ( [ mem_destroy_i ] { } ) always clobbers reg byte a +Statement [6] *((const byte*) MUSIC + (volatile byte) mem_destroy_i) ← ++ *((const byte*) MUSIC + (volatile byte) mem_destroy_i) [ mem_destroy_i ] ( [ mem_destroy_i ] { } ) always clobbers reg byte x +Statement [8] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto irq::@1 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [11] call *((const void()*) musicPlay) [ ] ( [ ] { } ) always clobbers reg byte a reg byte x reg byte y reg byte z +Statement [13] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto irq::@3 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [15] return [ ] ( [ ] { } ) always clobbers reg byte a reg byte x reg byte y +Statement [18] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $47 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [19] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $53 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [20] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | (byte) $40 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [21] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | (byte) $40 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [22] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [23] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [24] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) ← (byte) 1 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [27] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 [ main::dst#2 main::src#2 ] ( main:3 [ main::dst#2 main::src#2 ] { } ) always clobbers reg byte a +Statement [28] call *((const void()*) musicInit) [ ] ( main:3 [ ] { } ) always clobbers reg byte a reg byte x reg byte y reg byte z +Statement [30] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1+(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [31] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (byte) $ff [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [32] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & (byte) $7f [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [33] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [34] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_STACK)(void()) irq() [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [38] *((const nomodify byte*) DEFAULT_SCREEN + (byte) main::i#2) ← *((const byte*) MUSIC + (byte) main::i#2) [ main::i#2 ] ( main:3 [ main::i#2 ] { } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:6 [ main::i#2 main::i#1 ] +Statement [40] *((byte*) main::dst#2) ← *((byte*) main::src#2) [ main::dst#2 main::src#2 ] ( main:3 [ main::dst#2 main::src#2 ] { } ) always clobbers reg byte a reg byte y +Statement [49] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#4 << (byte) 4 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] ( memoryRemap:12 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } main:3::memoryRemap:17 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } main:3::memoryRemap:29 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } memoryRemapBlock:10::memoryRemap:44 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } main:3::memoryRemapBlock:25::memoryRemap:44 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:9 [ memoryRemap::remapBlocks#4 ] +Statement [51] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] ( memoryRemap:12 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } main:3::memoryRemap:17 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } main:3::memoryRemap:29 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemapBlock:10::memoryRemap:44 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } main:3::memoryRemapBlock:25::memoryRemap:44 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:14 [ memoryRemap::$1 ] -Statement [35] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (byte) $f0 [ memoryRemap::upperPageOffset#3 memoryRemap::$6 ] ( memoryRemap:5 [ memoryRemap::upperPageOffset#3 memoryRemap::$6 ] { } memoryRemap:16 [ main::mem_destroy#5 memoryRemap::upperPageOffset#3 memoryRemap::$6 ] { } memoryRemapBlock:1::memoryRemap:23 [ memoryRemap::upperPageOffset#3 memoryRemap::$6 ] { } memoryRemapBlock:14::memoryRemap:23 [ main::mem_destroy#5 memoryRemap::upperPageOffset#3 memoryRemap::$6 ] { } ) always clobbers reg byte a -Statement [37] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f [ memoryRemap::$6 memoryRemap::$8 ] ( memoryRemap:5 [ memoryRemap::$6 memoryRemap::$8 ] { } memoryRemap:16 [ main::mem_destroy#5 memoryRemap::$6 memoryRemap::$8 ] { } memoryRemapBlock:1::memoryRemap:23 [ memoryRemap::$6 memoryRemap::$8 ] { } memoryRemapBlock:14::memoryRemap:23 [ main::mem_destroy#5 memoryRemap::$6 memoryRemap::$8 ] { } ) always clobbers reg byte a +Statement [56] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (byte) $f0 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] ( memoryRemap:12 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } main:3::memoryRemap:17 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } main:3::memoryRemap:29 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } memoryRemapBlock:10::memoryRemap:44 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } main:3::memoryRemapBlock:25::memoryRemap:44 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } ) always clobbers reg byte a +Statement [58] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f [ memoryRemap::$6 memoryRemap::$8 ] ( memoryRemap:12 [ memoryRemap::$6 memoryRemap::$8 ] { } main:3::memoryRemap:17 [ memoryRemap::$6 memoryRemap::$8 ] { } main:3::memoryRemap:29 [ memoryRemap::$6 memoryRemap::$8 ] { } memoryRemapBlock:10::memoryRemap:44 [ memoryRemap::$6 memoryRemap::$8 ] { } main:3::memoryRemapBlock:25::memoryRemap:44 [ memoryRemap::$6 memoryRemap::$8 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:19 [ memoryRemap::$6 ] Statement asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } always clobbers reg byte a reg byte x reg byte y reg byte z -Statement [3] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 [ main::dst#2 main::src#2 ] ( [ main::dst#2 main::src#2 ] { } ) always clobbers reg byte a -Statement [4] call *((const void()*) musicInit) [ ] ( [ ] { } ) always clobbers reg byte a reg byte x reg byte y reg byte z -Statement [7] *((byte*) main::mem_destroy#3) ← (byte) 0 [ main::mem_destroy#3 ] ( [ main::mem_destroy#3 ] { } ) always clobbers reg byte a reg byte y -Statement [9] if((byte*) main::mem_destroy#1!=(const nomodify byte*) MUSIC_END) goto main::@10 [ main::mem_destroy#1 ] ( [ main::mem_destroy#1 ] { } ) always clobbers reg byte a -Statement [12] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto main::@5 [ main::mem_destroy#5 ] ( [ main::mem_destroy#5 ] { } ) always clobbers reg byte a -Statement [15] call *((const void()*) musicPlay) [ main::mem_destroy#5 ] ( [ main::mem_destroy#5 ] { } ) always clobbers reg byte a reg byte x reg byte y reg byte z -Statement [18] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto main::@7 [ main::mem_destroy#5 ] ( [ main::mem_destroy#5 ] { } ) always clobbers reg byte a -Statement [19] *((byte*) main::dst#2) ← *((byte*) main::src#2) [ main::dst#2 main::src#2 ] ( [ main::dst#2 main::src#2 ] { } ) always clobbers reg byte a reg byte y -Statement [28] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#3 << (byte) 4 [ memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] ( memoryRemap:5 [ memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] { } memoryRemap:16 [ main::mem_destroy#5 memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] { } memoryRemapBlock:1::memoryRemap:23 [ memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] { } memoryRemapBlock:14::memoryRemap:23 [ main::mem_destroy#5 memoryRemap::lowerPageOffset#3 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 ] { } ) always clobbers reg byte a -Statement [30] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f [ memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] ( memoryRemap:5 [ memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemap:16 [ main::mem_destroy#5 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemapBlock:1::memoryRemap:23 [ memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemapBlock:14::memoryRemap:23 [ main::mem_destroy#5 memoryRemap::remapBlocks#3 memoryRemap::upperPageOffset#3 memoryRemap::$1 memoryRemap::$3 ] { } ) always clobbers reg byte a -Statement [35] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (byte) $f0 [ memoryRemap::upperPageOffset#3 memoryRemap::$6 ] ( memoryRemap:5 [ memoryRemap::upperPageOffset#3 memoryRemap::$6 ] { } memoryRemap:16 [ main::mem_destroy#5 memoryRemap::upperPageOffset#3 memoryRemap::$6 ] { } memoryRemapBlock:1::memoryRemap:23 [ memoryRemap::upperPageOffset#3 memoryRemap::$6 ] { } memoryRemapBlock:14::memoryRemap:23 [ main::mem_destroy#5 memoryRemap::upperPageOffset#3 memoryRemap::$6 ] { } ) always clobbers reg byte a -Statement [37] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f [ memoryRemap::$6 memoryRemap::$8 ] ( memoryRemap:5 [ memoryRemap::$6 memoryRemap::$8 ] { } memoryRemap:16 [ main::mem_destroy#5 memoryRemap::$6 memoryRemap::$8 ] { } memoryRemapBlock:1::memoryRemap:23 [ memoryRemap::$6 memoryRemap::$8 ] { } memoryRemapBlock:14::memoryRemap:23 [ main::mem_destroy#5 memoryRemap::$6 memoryRemap::$8 ] { } ) always clobbers reg byte a +Statement [1] (volatile byte) mem_destroy_i ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER [ mem_destroy_i ] ( [ mem_destroy_i ] { } ) always clobbers reg byte a +Statement [6] *((const byte*) MUSIC + (volatile byte) mem_destroy_i) ← ++ *((const byte*) MUSIC + (volatile byte) mem_destroy_i) [ mem_destroy_i ] ( [ mem_destroy_i ] { } ) always clobbers reg byte x +Statement [8] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto irq::@1 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [11] call *((const void()*) musicPlay) [ ] ( [ ] { } ) always clobbers reg byte a reg byte x reg byte y reg byte z +Statement [13] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto irq::@3 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [15] return [ ] ( [ ] { } ) always clobbers reg byte a reg byte x reg byte y +Statement [18] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $47 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [19] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $53 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [20] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | (byte) $40 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [21] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | (byte) $40 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [22] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [23] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [24] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) ← (byte) 1 [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [27] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 [ main::dst#2 main::src#2 ] ( main:3 [ main::dst#2 main::src#2 ] { } ) always clobbers reg byte a +Statement [28] call *((const void()*) musicInit) [ ] ( main:3 [ ] { } ) always clobbers reg byte a reg byte x reg byte y reg byte z +Statement [30] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1+(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [31] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (byte) $ff [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [32] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & (byte) $7f [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [33] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [34] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_STACK)(void()) irq() [ ] ( main:3 [ ] { } ) always clobbers reg byte a +Statement [38] *((const nomodify byte*) DEFAULT_SCREEN + (byte) main::i#2) ← *((const byte*) MUSIC + (byte) main::i#2) [ main::i#2 ] ( main:3 [ main::i#2 ] { } ) always clobbers reg byte a +Statement [40] *((byte*) main::dst#2) ← *((byte*) main::src#2) [ main::dst#2 main::src#2 ] ( main:3 [ main::dst#2 main::src#2 ] { } ) always clobbers reg byte a reg byte y +Statement [49] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#4 << (byte) 4 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] ( memoryRemap:12 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } main:3::memoryRemap:17 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } main:3::memoryRemap:29 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } memoryRemapBlock:10::memoryRemap:44 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } main:3::memoryRemapBlock:25::memoryRemap:44 [ memoryRemap::lowerPageOffset#4 memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 ] { } ) always clobbers reg byte a +Statement [51] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] ( memoryRemap:12 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } main:3::memoryRemap:17 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } main:3::memoryRemap:29 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemapBlock:10::memoryRemap:44 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } main:3::memoryRemapBlock:25::memoryRemap:44 [ memoryRemap::remapBlocks#4 memoryRemap::upperPageOffset#4 memoryRemap::$1 memoryRemap::$3 ] { } ) always clobbers reg byte a +Statement [56] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (byte) $f0 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] ( memoryRemap:12 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } main:3::memoryRemap:17 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } main:3::memoryRemap:29 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } memoryRemapBlock:10::memoryRemap:44 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } main:3::memoryRemapBlock:25::memoryRemap:44 [ memoryRemap::upperPageOffset#4 memoryRemap::$6 ] { } ) always clobbers reg byte a +Statement [58] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f [ memoryRemap::$6 memoryRemap::$8 ] ( memoryRemap:12 [ memoryRemap::$6 memoryRemap::$8 ] { } main:3::memoryRemap:17 [ memoryRemap::$6 memoryRemap::$8 ] { } main:3::memoryRemap:29 [ memoryRemap::$6 memoryRemap::$8 ] { } memoryRemapBlock:10::memoryRemap:44 [ memoryRemap::$6 memoryRemap::$8 ] { } main:3::memoryRemapBlock:25::memoryRemap:44 [ memoryRemap::$6 memoryRemap::$8 ] { } ) always clobbers reg byte a Statement asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } always clobbers reg byte a reg byte x reg byte y reg byte z Potential registers zp[2]:2 [ main::dst#2 main::dst#1 ] : zp[2]:2 , Potential registers zp[2]:4 [ main::src#2 main::src#1 ] : zp[2]:4 , -Potential registers zp[2]:6 [ main::mem_destroy#3 main::mem_destroy#5 main::mem_destroy#1 ] : zp[2]:6 , -Potential registers zp[2]:8 [ memoryRemap::lowerPageOffset#3 ] : zp[2]:8 , -Potential registers zp[1]:10 [ memoryRemap::remapBlocks#3 ] : zp[1]:10 , reg byte x , reg byte y , reg byte z , -Potential registers zp[2]:11 [ memoryRemap::upperPageOffset#3 ] : zp[2]:11 , +Potential registers zp[1]:6 [ main::i#2 main::i#1 ] : zp[1]:6 , reg byte x , reg byte y , reg byte z , +Potential registers zp[2]:7 [ memoryRemap::lowerPageOffset#4 ] : zp[2]:7 , +Potential registers zp[1]:9 [ memoryRemap::remapBlocks#4 ] : zp[1]:9 , reg byte x , reg byte y , reg byte z , +Potential registers zp[2]:10 [ memoryRemap::upperPageOffset#4 ] : zp[2]:10 , +Potential registers zp[1]:12 [ mem_destroy_i ] : zp[1]:12 , Potential registers zp[1]:13 [ memoryRemap::$0 ] : zp[1]:13 , reg byte a , reg byte x , reg byte y , reg byte z , Potential registers zp[1]:14 [ memoryRemap::$1 ] : zp[1]:14 , reg byte x , reg byte y , reg byte z , Potential registers zp[1]:15 [ memoryRemap::$2 ] : zp[1]:15 , reg byte a , reg byte x , reg byte y , reg byte z , @@ -1637,49 +1946,57 @@ Potential registers zp[1]:21 [ memoryRemap::$8 ] : zp[1]:21 , reg byte a , reg b Potential registers zp[1]:22 [ memoryRemap::$9 ] : zp[1]:22 , reg byte a , reg byte x , reg byte y , reg byte z , REGISTER UPLIFT SCOPES -Uplift Scope [memoryRemap] 2,002: zp[1]:13 [ memoryRemap::$0 ] 2,002: zp[1]:15 [ memoryRemap::$2 ] 2,002: zp[1]:16 [ memoryRemap::$3 ] 2,002: zp[1]:17 [ memoryRemap::$4 ] 2,002: zp[1]:18 [ memoryRemap::$5 ] 2,002: zp[1]:20 [ memoryRemap::$7 ] 2,002: zp[1]:21 [ memoryRemap::$8 ] 2,002: zp[1]:22 [ memoryRemap::$9 ] 667.33: zp[1]:14 [ memoryRemap::$1 ] 667.33: zp[1]:19 [ memoryRemap::$6 ] 500.5: zp[2]:8 [ memoryRemap::lowerPageOffset#3 ] 200.2: zp[1]:10 [ memoryRemap::remapBlocks#3 ] 182: zp[2]:11 [ memoryRemap::upperPageOffset#3 ] -Uplift Scope [main] 111.75: zp[2]:6 [ main::mem_destroy#3 main::mem_destroy#5 main::mem_destroy#1 ] 30.25: zp[2]:4 [ main::src#2 main::src#1 ] 25.67: zp[2]:2 [ main::dst#2 main::dst#1 ] +Uplift Scope [memoryRemap] 2,002: zp[1]:13 [ memoryRemap::$0 ] 2,002: zp[1]:15 [ memoryRemap::$2 ] 2,002: zp[1]:16 [ memoryRemap::$3 ] 2,002: zp[1]:17 [ memoryRemap::$4 ] 2,002: zp[1]:18 [ memoryRemap::$5 ] 2,002: zp[1]:20 [ memoryRemap::$7 ] 2,002: zp[1]:21 [ memoryRemap::$8 ] 2,002: zp[1]:22 [ memoryRemap::$9 ] 667.33: zp[1]:14 [ memoryRemap::$1 ] 667.33: zp[1]:19 [ memoryRemap::$6 ] 500.5: zp[2]:7 [ memoryRemap::lowerPageOffset#4 ] 200.2: zp[1]:9 [ memoryRemap::remapBlocks#4 ] 182: zp[2]:10 [ memoryRemap::upperPageOffset#4 ] +Uplift Scope [main] 670.33: zp[1]:6 [ main::i#2 main::i#1 ] 277.75: zp[2]:4 [ main::src#2 main::src#1 ] 235.67: zp[2]:2 [ main::dst#2 main::dst#1 ] +Uplift Scope [] 5: zp[1]:12 [ mem_destroy_i ] Uplift Scope [MOS6526_CIA] Uplift Scope [MOS6569_VICII] Uplift Scope [MOS6581_SID] Uplift Scope [MOS4569_VICIII] Uplift Scope [MEGA65_VICIV] Uplift Scope [memoryRemapBlock] -Uplift Scope [] +Uplift Scope [irq] +Uplift Scope [__start] -Uplifting [memoryRemap] best 5266 combination reg byte a [ memoryRemap::$0 ] reg byte a [ memoryRemap::$2 ] reg byte a [ memoryRemap::$3 ] zp[1]:17 [ memoryRemap::$4 ] zp[1]:18 [ memoryRemap::$5 ] zp[1]:20 [ memoryRemap::$7 ] zp[1]:21 [ memoryRemap::$8 ] zp[1]:22 [ memoryRemap::$9 ] zp[1]:14 [ memoryRemap::$1 ] zp[1]:19 [ memoryRemap::$6 ] zp[2]:8 [ memoryRemap::lowerPageOffset#3 ] zp[1]:10 [ memoryRemap::remapBlocks#3 ] zp[2]:11 [ memoryRemap::upperPageOffset#3 ] +Uplifting [memoryRemap] best 3900 combination reg byte a [ memoryRemap::$0 ] reg byte a [ memoryRemap::$2 ] reg byte a [ memoryRemap::$3 ] zp[1]:17 [ memoryRemap::$4 ] zp[1]:18 [ memoryRemap::$5 ] zp[1]:20 [ memoryRemap::$7 ] zp[1]:21 [ memoryRemap::$8 ] zp[1]:22 [ memoryRemap::$9 ] zp[1]:14 [ memoryRemap::$1 ] zp[1]:19 [ memoryRemap::$6 ] zp[2]:7 [ memoryRemap::lowerPageOffset#4 ] zp[1]:9 [ memoryRemap::remapBlocks#4 ] zp[2]:10 [ memoryRemap::upperPageOffset#4 ] Limited combination testing to 100 combinations of 25000000 possible. -Uplifting [main] best 5266 combination zp[2]:6 [ main::mem_destroy#3 main::mem_destroy#5 main::mem_destroy#1 ] zp[2]:4 [ main::src#2 main::src#1 ] zp[2]:2 [ main::dst#2 main::dst#1 ] -Uplifting [MOS6526_CIA] best 5266 combination -Uplifting [MOS6569_VICII] best 5266 combination -Uplifting [MOS6581_SID] best 5266 combination -Uplifting [MOS4569_VICIII] best 5266 combination -Uplifting [MEGA65_VICIV] best 5266 combination -Uplifting [memoryRemapBlock] best 5266 combination -Uplifting [] best 5266 combination +Uplifting [main] best 3240 combination reg byte x [ main::i#2 main::i#1 ] zp[2]:4 [ main::src#2 main::src#1 ] zp[2]:2 [ main::dst#2 main::dst#1 ] +Uplifting [] best 3240 combination zp[1]:12 [ mem_destroy_i ] +Uplifting [MOS6526_CIA] best 3240 combination +Uplifting [MOS6569_VICII] best 3240 combination +Uplifting [MOS6581_SID] best 3240 combination +Uplifting [MOS4569_VICIII] best 3240 combination +Uplifting [MEGA65_VICIV] best 3240 combination +Uplifting [memoryRemapBlock] best 3240 combination +Uplifting [irq] best 3240 combination +Uplifting [__start] best 3240 combination Attempting to uplift remaining variables inzp[1]:17 [ memoryRemap::$4 ] -Uplifting [memoryRemap] best 5260 combination reg byte a [ memoryRemap::$4 ] +Uplifting [memoryRemap] best 3234 combination reg byte a [ memoryRemap::$4 ] Attempting to uplift remaining variables inzp[1]:18 [ memoryRemap::$5 ] -Uplifting [memoryRemap] best 5254 combination reg byte a [ memoryRemap::$5 ] +Uplifting [memoryRemap] best 3228 combination reg byte a [ memoryRemap::$5 ] Attempting to uplift remaining variables inzp[1]:20 [ memoryRemap::$7 ] -Uplifting [memoryRemap] best 5248 combination reg byte a [ memoryRemap::$7 ] +Uplifting [memoryRemap] best 3222 combination reg byte a [ memoryRemap::$7 ] Attempting to uplift remaining variables inzp[1]:21 [ memoryRemap::$8 ] -Uplifting [memoryRemap] best 5242 combination reg byte a [ memoryRemap::$8 ] +Uplifting [memoryRemap] best 3216 combination reg byte a [ memoryRemap::$8 ] Attempting to uplift remaining variables inzp[1]:22 [ memoryRemap::$9 ] -Uplifting [memoryRemap] best 5236 combination reg byte a [ memoryRemap::$9 ] +Uplifting [memoryRemap] best 3210 combination reg byte a [ memoryRemap::$9 ] Attempting to uplift remaining variables inzp[1]:14 [ memoryRemap::$1 ] -Uplifting [memoryRemap] best 5236 combination zp[1]:14 [ memoryRemap::$1 ] +Uplifting [memoryRemap] best 3210 combination zp[1]:14 [ memoryRemap::$1 ] Attempting to uplift remaining variables inzp[1]:19 [ memoryRemap::$6 ] -Uplifting [memoryRemap] best 5236 combination zp[1]:19 [ memoryRemap::$6 ] -Attempting to uplift remaining variables inzp[1]:10 [ memoryRemap::remapBlocks#3 ] -Uplifting [memoryRemap] best 5223 combination reg byte z [ memoryRemap::remapBlocks#3 ] -Allocated (was zp[2]:11) zp[2]:10 [ memoryRemap::upperPageOffset#3 ] -Allocated (was zp[1]:14) zp[1]:12 [ memoryRemap::$1 ] -Allocated (was zp[1]:19) zp[1]:13 [ memoryRemap::$6 ] +Uplifting [memoryRemap] best 3210 combination zp[1]:19 [ memoryRemap::$6 ] +Attempting to uplift remaining variables inzp[1]:9 [ memoryRemap::remapBlocks#4 ] +Uplifting [memoryRemap] best 3194 combination reg byte z [ memoryRemap::remapBlocks#4 ] +Attempting to uplift remaining variables inzp[1]:12 [ mem_destroy_i ] +Uplifting [] best 3194 combination zp[1]:12 [ mem_destroy_i ] +Allocated (was zp[2]:7) zp[2]:6 [ memoryRemap::lowerPageOffset#4 ] +Allocated (was zp[2]:10) zp[2]:8 [ memoryRemap::upperPageOffset#4 ] +Allocated (was zp[1]:12) zp[1]:10 [ mem_destroy_i ] +Allocated (was zp[1]:14) zp[1]:11 [ memoryRemap::$1 ] +Allocated (was zp[1]:19) zp[1]:12 [ memoryRemap::$6 ] ASSEMBLER BEFORE OPTIMIZATION // File Comments -// SID music located in another bank being played using memory mapping on MEGA65 +// SID music located in another bank being played in a raster IRQ using memory mapping on the MEGA65 // Music is Cybernoid II by Jeroen Tel released in 1988 by Hewson https://csdb.dk/sid/?id=28140 // SID relocated using http://www.linusakesson.net/software/sidreloc/index.php // Upstart @@ -1696,42 +2013,223 @@ ASSEMBLER BEFORE OPTIMIZATION .segment Basic .byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0 .byte $15, $20, $14, $00, $9e, $20 // 20 SYS -.text toIntString(main) // NNNN +.text toIntString(__start) // NNNN .byte $00, $00, $00 // // Global Constants & labels + // Value that disables all CIA interrupts when stored to the CIA Interrupt registers + .const CIA_INTERRUPT_CLEAR = $7f + // Bits for the VICII IRQ Status/Enable Registers + .const IRQ_RASTER = 1 + // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written + .const PROCPORT_DDR_MEMORY_MASK = 7 + // RAM in 0xA000, 0xE000 I/O in 0xD000 + .const PROCPORT_RAM_IO = 5 + .const OFFSET_STRUCT_MOS4569_VICIII_KEY = $2f + .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLB = $31 + .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLC = $54 + .const OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO = $5c + .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12 + .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11 + .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a + .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19 .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 + // Processor port data direction register + .label PROCPORT_DDR = 0 + // Processor Port Register controlling RAM/ROM configuration and the datasette + .label PROCPORT = 1 // The VIC-II MOS 6567/6569 .label VICII = $d000 + // The VIC III MOS 4567/4569 + .label VICIII = $d000 + // The VIC IV + .label VICIV = $d000 + // Default address of screen character matrix + .label DEFAULT_SCREEN = $800 + // The CIA#1: keyboard matrix, joystick #1/#2 + .label CIA1 = $dc00 + // The vector used when the HARDWARE serves IRQ interrupts + .label HARDWARE_IRQ = $fffe // Address after the end of the music .label MUSIC_END = $5200 // Pointer to the music init routine .label musicInit = MUSIC // Pointer to the music play routine .label musicPlay = MUSIC+3 + // Index used to destroy unmapped music memory (to demonstrate that mapping works) + .label mem_destroy_i = $a .segment Code + // __start +__start: { + jmp __init1 + // __start::__init1 + __init1: + // [1] (volatile byte) mem_destroy_i ← (byte) 0 -- vbuz1=vbuc1 + lda #0 + sta.z mem_destroy_i + // [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1] + __b1_from___init1: + jmp __b1 + // __start::@1 + __b1: + // [3] call main + jsr main + jmp __breturn + // __start::@return + __breturn: + // [4] return + rts +} + // irq +// Raster IRQ routine +irq: { + // entry interrupt(HARDWARE_STACK) + pha + txa + pha + tya + pha + // [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 + // Acknowledge the IRQ + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS + // [6] *((const byte*) MUSIC + (volatile byte) mem_destroy_i) ← ++ *((const byte*) MUSIC + (volatile byte) mem_destroy_i) -- pbuc1_derefidx_vbuz1=_inc_pbuc1_derefidx_vbuz1 + ldx.z mem_destroy_i + inc MUSIC,x + // [7] (volatile byte) mem_destroy_i ← ++ (volatile byte) mem_destroy_i -- vbuz1=_inc_vbuz1 + inc.z mem_destroy_i + jmp __b1 + // Wait for the raster + // irq::@1 + __b1: + // [8] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto irq::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 + lda #$ff + cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + bne __b1 + jmp __b2 + // irq::@2 + __b2: + // [9] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1 + inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + // [10] call memoryRemapBlock + // Remap memory to put music at $4000 + // [43] phi from irq::@2 to memoryRemapBlock [phi:irq::@2->memoryRemapBlock] + memoryRemapBlock_from___b2: + jsr memoryRemapBlock + jmp __b5 + // irq::@5 + __b5: + // [11] call *((const void()*) musicPlay) + // Play remapped SID + jsr musicPlay + // [12] call memoryRemap + // Reset memory mapping + // [46] phi from irq::@5 to memoryRemap [phi:irq::@5->memoryRemap] + memoryRemap_from___b5: + // [46] phi (word) memoryRemap::upperPageOffset#4 = (byte) 0 [phi:irq::@5->memoryRemap#0] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.upperPageOffset + lda #>0 + sta.z memoryRemap.upperPageOffset+1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (byte) 0 [phi:irq::@5->memoryRemap#1] -- vbuzz=vbuc1 + ldz #0 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (byte) 0 [phi:irq::@5->memoryRemap#2] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.lowerPageOffset + lda #>0 + sta.z memoryRemap.lowerPageOffset+1 + jsr memoryRemap + jmp __b3 + // Wait for the raster + // irq::@3 + __b3: + // [13] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto irq::@3 -- _deref_pbuc1_eq_vbuc2_then_la1 + lda #$ff + cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + beq __b3 + jmp __b4 + // irq::@4 + __b4: + // [14] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1 + dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + jmp __breturn + // irq::@return + __breturn: + // [15] return - exit interrupt(HARDWARE_STACK) + pla + tay + pla + tax + pla + rti +} // main main: { .label dst = 2 .label src = 4 - // Pointer to (unmapped) $4000 used for overwriting to demonstrate the mapping works - .label mem_destroy = 6 // asm { sei } // Stop IRQ's sei - // [1] call memoryRemapBlock + // [17] call memoryRemap + // Map memory to BANK 0 : 0x00XXXX - giving access to I/O + // [46] phi from main to memoryRemap [phi:main->memoryRemap] + memoryRemap_from_main: + // [46] phi (word) memoryRemap::upperPageOffset#4 = (byte) 0 [phi:main->memoryRemap#0] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.upperPageOffset + lda #>0 + sta.z memoryRemap.upperPageOffset+1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (byte) 0 [phi:main->memoryRemap#1] -- vbuzz=vbuc1 + ldz #0 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (byte) 0 [phi:main->memoryRemap#2] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.lowerPageOffset + lda #>0 + sta.z memoryRemap.lowerPageOffset+1 + jsr memoryRemap + jmp __b6 + // main::@6 + __b6: + // [18] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $47 -- _deref_pbuc1=vbuc2 + // Enable MEGA65 features + lda #$47 + sta VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY + // [19] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $53 -- _deref_pbuc1=vbuc2 + lda #$53 + sta VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY + // [20] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | (byte) $40 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2 + // Enable 48MHz fast mode + lda #$40 + ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB + // [21] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | (byte) $40 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2 + lda #$40 + ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC + // [22] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK -- _deref_pbuc1=vbuc2 + // no kernal or BASIC rom visible + lda #PROCPORT_DDR_MEMORY_MASK + sta PROCPORT_DDR + // [23] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO -- _deref_pbuc1=vbuc2 + lda #PROCPORT_RAM_IO + sta PROCPORT + // [24] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) ← (byte) 1 -- _deref_pbuc1=vbuc2 + // open sideborder + lda #1 + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO + // [25] call memoryRemapBlock // Remap [$4000-$5fff] to point to [$10000-$11fff] - // [22] phi from main to memoryRemapBlock [phi:main->memoryRemapBlock] - memoryRemapBlock_from_main: + // [43] phi from main::@6 to memoryRemapBlock [phi:main::@6->memoryRemapBlock] + memoryRemapBlock_from___b6: jsr memoryRemapBlock - // [2] phi from main to main::@1 [phi:main->main::@1] - __b1_from_main: - // [2] phi (byte*) main::src#2 = (const byte*) upperCodeData [phi:main->main::@1#0] -- pbuz1=pbuc1 + // [26] phi from main::@6 to main::@1 [phi:main::@6->main::@1] + __b1_from___b6: + // [26] phi (byte*) main::src#2 = (const byte*) upperCodeData [phi:main::@6->main::@1#0] -- pbuz1=pbuc1 lda #upperCodeData sta.z src+1 - // [2] phi (byte*) main::dst#2 = (const byte*) MUSIC [phi:main->main::@1#1] -- pbuz1=pbuc1 + // [26] phi (byte*) main::dst#2 = (const byte*) MUSIC [phi:main::@6->main::@1#1] -- pbuz1=pbuc1 lda #MUSIC @@ -1740,7 +2238,7 @@ main: { // Transfer banked code/data to upper memory ($11000) // main::@1 __b1: - // [3] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 -- pbuz1_lt_pbuc1_then_la1 + // [27] if((byte*) main::dst#2<(const nomodify byte*) MUSIC_END) goto main::@2 -- pbuz1_lt_pbuc1_then_la1 lda.z dst+1 cmp #>MUSIC_END bcc __b2 @@ -1752,140 +2250,94 @@ main: { jmp __b3 // main::@3 __b3: - // [4] call *((const void()*) musicInit) + // [28] call *((const void()*) musicInit) // Initialize SID memory is still remapped) jsr musicInit - // [5] call memoryRemap + // [29] call memoryRemap // Reset memory mapping - // [25] phi from main::@3 to memoryRemap [phi:main::@3->memoryRemap] + // [46] phi from main::@3 to memoryRemap [phi:main::@3->memoryRemap] memoryRemap_from___b3: - // [25] phi (word) memoryRemap::upperPageOffset#3 = (byte) 0 [phi:main::@3->memoryRemap#0] -- vwuz1=vbuc1 + // [46] phi (word) memoryRemap::upperPageOffset#4 = (byte) 0 [phi:main::@3->memoryRemap#0] -- vwuz1=vbuc1 lda #<0 sta.z memoryRemap.upperPageOffset lda #>0 sta.z memoryRemap.upperPageOffset+1 - // [25] phi (byte) memoryRemap::remapBlocks#3 = (byte) 0 [phi:main::@3->memoryRemap#1] -- vbuzz=vbuc1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (byte) 0 [phi:main::@3->memoryRemap#1] -- vbuzz=vbuc1 ldz #0 - // [25] phi (word) memoryRemap::lowerPageOffset#3 = (byte) 0 [phi:main::@3->memoryRemap#2] -- vwuz1=vbuc1 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (byte) 0 [phi:main::@3->memoryRemap#2] -- vwuz1=vbuc1 lda #<0 sta.z memoryRemap.lowerPageOffset lda #>0 sta.z memoryRemap.lowerPageOffset+1 jsr memoryRemap - // [6] phi from main::@3 to main::@4 [phi:main::@3->main::@4] - __b4_from___b3: - // [6] phi (byte*) main::mem_destroy#3 = (const byte*) MUSIC [phi:main::@3->main::@4#0] -- pbuz1=pbuc1 - lda #MUSIC - sta.z mem_destroy+1 + jmp __b7 + // main::@7 + __b7: + // [30] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1+(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 + // Set up raster interrupts C64 style + // Disable CIA 1 Timer IRQ + lda #CIA_INTERRUPT_CLEAR + sta CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT + // [31] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (byte) $ff -- _deref_pbuc1=vbuc2 + // Set raster line to 0xff + lda #$ff + sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + // [32] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 + lda #$7f + and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + // [33] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 + // Enable Raster Interrupt + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE + // [34] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_STACK)(void()) irq() -- _deref_qprc1=pprc2 + // Set the IRQ routine + lda #irq + sta HARDWARE_IRQ+1 + // asm { cli } + // Enable IRQ + cli + // [36] phi from main::@7 to main::@4 [phi:main::@7->main::@4] + __b4_from___b7: jmp __b4 // main::@4 __b4: - // [7] *((byte*) main::mem_destroy#3) ← (byte) 0 -- _deref_pbuz1=vbuc1 - // Overwrite data in the unmapped memory where the music is mapped in (to demonstrate that mapping works) - lda #0 - ldy #0 - sta (mem_destroy),y - // [8] (byte*) main::mem_destroy#1 ← ++ (byte*) main::mem_destroy#3 -- pbuz1=_inc_pbuz1 - inw.z mem_destroy - // [9] if((byte*) main::mem_destroy#1!=(const nomodify byte*) MUSIC_END) goto main::@10 -- pbuz1_neq_pbuc1_then_la1 - lda.z mem_destroy+1 - cmp #>MUSIC_END - bne __b10_from___b4 - lda.z mem_destroy - cmp #main::@5] - __b5_from___b4: - // [11] phi (byte*) main::mem_destroy#5 = (const byte*) MUSIC [phi:main::@4->main::@5#0] -- pbuz1=pbuc1 - lda #MUSIC - sta.z mem_destroy+1 - jmp __b5 - // [10] phi from main::@4 to main::@10 [phi:main::@4->main::@10] - __b10_from___b4: - jmp __b10 - // main::@10 - __b10: - // [11] phi from main::@10 main::@5 to main::@5 [phi:main::@10/main::@5->main::@5] - __b5_from___b10: - __b5_from___b5: - // [11] phi (byte*) main::mem_destroy#5 = (byte*) main::mem_destroy#1 [phi:main::@10/main::@5->main::@5#0] -- register_copy - jmp __b5 - // Wait for the raster + // [37] if((byte) main::i#2<(byte) $f0) goto main::@5 -- vbuxx_lt_vbuc1_then_la1 + cpx #$f0 + bcc __b5 + // [36] phi from main::@4 to main::@4 [phi:main::@4->main::@4] + __b4_from___b4: + // [36] phi (byte) main::i#2 = (byte) 0 [phi:main::@4->main::@4#0] -- vbuxx=vbuc1 + ldx #0 + jmp __b4 // main::@5 __b5: - // [12] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto main::@5 -- _deref_pbuc1_neq_vbuc2_then_la1 - lda #$ff - cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER - bne __b5_from___b5 - jmp __b6 - // main::@6 - __b6: - // [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1 - inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - // [14] call memoryRemapBlock - // Remap memory to put music at $4000 - // [22] phi from main::@6 to memoryRemapBlock [phi:main::@6->memoryRemapBlock] - memoryRemapBlock_from___b6: - jsr memoryRemapBlock - jmp __b8 - // main::@8 - __b8: - // [15] call *((const void()*) musicPlay) - // Play remapped SID - jsr musicPlay - // [16] call memoryRemap - // Reset memory mapping - // [25] phi from main::@8 to memoryRemap [phi:main::@8->memoryRemap] - memoryRemap_from___b8: - // [25] phi (word) memoryRemap::upperPageOffset#3 = (byte) 0 [phi:main::@8->memoryRemap#0] -- vwuz1=vbuc1 - lda #<0 - sta.z memoryRemap.upperPageOffset - lda #>0 - sta.z memoryRemap.upperPageOffset+1 - // [25] phi (byte) memoryRemap::remapBlocks#3 = (byte) 0 [phi:main::@8->memoryRemap#1] -- vbuzz=vbuc1 - ldz #0 - // [25] phi (word) memoryRemap::lowerPageOffset#3 = (byte) 0 [phi:main::@8->memoryRemap#2] -- vwuz1=vbuc1 - lda #<0 - sta.z memoryRemap.lowerPageOffset - lda #>0 - sta.z memoryRemap.lowerPageOffset+1 - jsr memoryRemap - jmp __b9 - // main::@9 - __b9: - // [17] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1 - dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - jmp __b7 - // Wait for the raster - // main::@7 - __b7: - // [18] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto main::@7 -- _deref_pbuc1_eq_vbuc2_then_la1 - lda #$ff - cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER - beq __b7 - // [6] phi from main::@7 to main::@4 [phi:main::@7->main::@4] - __b4_from___b7: - // [6] phi (byte*) main::mem_destroy#3 = (byte*) main::mem_destroy#5 [phi:main::@7->main::@4#0] -- register_copy + // [38] *((const nomodify byte*) DEFAULT_SCREEN + (byte) main::i#2) ← *((const byte*) MUSIC + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MUSIC,x + sta DEFAULT_SCREEN,x + // [39] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx + inx + // [36] phi from main::@5 to main::@4 [phi:main::@5->main::@4] + __b4_from___b5: + // [36] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@4#0] -- register_copy jmp __b4 // main::@2 __b2: - // [19] *((byte*) main::dst#2) ← *((byte*) main::src#2) -- _deref_pbuz1=_deref_pbuz2 + // [40] *((byte*) main::dst#2) ← *((byte*) main::src#2) -- _deref_pbuz1=_deref_pbuz2 ldy #0 lda (src),y ldy #0 sta (dst),y - // [20] (byte*) main::dst#1 ← ++ (byte*) main::dst#2 -- pbuz1=_inc_pbuz1 + // [41] (byte*) main::dst#1 ← ++ (byte*) main::dst#2 -- pbuz1=_inc_pbuz1 inw.z dst - // [21] (byte*) main::src#1 ← ++ (byte*) main::src#2 -- pbuz1=_inc_pbuz1 + // [42] (byte*) main::src#1 ← ++ (byte*) main::src#2 -- pbuz1=_inc_pbuz1 inw.z src - // [2] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + // [26] phi from main::@2 to main::@1 [phi:main::@2->main::@1] __b1_from___b2: - // [2] phi (byte*) main::src#2 = (byte*) main::src#1 [phi:main::@2->main::@1#0] -- register_copy - // [2] phi (byte*) main::dst#2 = (byte*) main::dst#1 [phi:main::@2->main::@1#1] -- register_copy + // [26] phi (byte*) main::src#2 = (byte*) main::src#1 [phi:main::@2->main::@1#0] -- register_copy + // [26] phi (byte*) main::dst#2 = (byte*) main::dst#1 [phi:main::@2->main::@1#1] -- register_copy jmp __b1 } // memoryRemapBlock @@ -1898,17 +2350,17 @@ memoryRemapBlock: { .const pageOffset = $100-$40 .const block = $40>>5 .const blockBits = 1<memoryRemap] + // [44] call memoryRemap + // [46] phi from memoryRemapBlock to memoryRemap [phi:memoryRemapBlock->memoryRemap] memoryRemap_from_memoryRemapBlock: - // [25] phi (word) memoryRemap::upperPageOffset#3 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#0] -- vwuz1=vwuc1 + // [46] phi (word) memoryRemap::upperPageOffset#4 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#0] -- vwuz1=vwuc1 lda #pageOffset sta.z memoryRemap.upperPageOffset+1 - // [25] phi (byte) memoryRemap::remapBlocks#3 = (const byte) memoryRemapBlock::blockBits#0 [phi:memoryRemapBlock->memoryRemap#1] -- vbuzz=vbuc1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (const byte) memoryRemapBlock::blockBits#0 [phi:memoryRemapBlock->memoryRemap#1] -- vbuzz=vbuc1 ldz #blockBits - // [25] phi (word) memoryRemap::lowerPageOffset#3 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#2] -- vwuz1=vwuc1 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#2] -- vwuz1=vwuc1 lda #pageOffset @@ -1917,7 +2369,7 @@ memoryRemapBlock: { jmp __breturn // memoryRemapBlock::@return __breturn: - // [24] return + // [45] return rts } // memoryRemap @@ -1945,50 +2397,50 @@ memoryRemapBlock: { // - If block 5 ($a000-$bfff) is remapped it will point to upperPageOffset*$100 + $a000. // - If block 6 ($c000-$dfff) is remapped it will point to upperPageOffset*$100 + $c000. // - If block 7 ($e000-$ffff) is remapped it will point to upperPageOffset*$100 + $e000. -// memoryRemap(byte register(Z) remapBlocks, word zp(8) lowerPageOffset, word zp($a) upperPageOffset) +// memoryRemap(byte register(Z) remapBlocks, word zp(6) lowerPageOffset, word zp(8) upperPageOffset) memoryRemap: { .label aVal = $fc .label xVal = $fd .label yVal = $fe .label zVal = $ff - .label __1 = $c - .label __6 = $d - .label lowerPageOffset = 8 - .label upperPageOffset = $a - // [26] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#3 -- vbuaa=_lo_vwuz1 + .label __1 = $b + .label __6 = $c + .label lowerPageOffset = 6 + .label upperPageOffset = 8 + // [47] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerPageOffset#4 -- vbuaa=_lo_vwuz1 lda.z lowerPageOffset - // [27] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 -- _deref_pbuc1=vbuaa + // [48] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 -- _deref_pbuc1=vbuaa sta aVal - // [28] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#3 << (byte) 4 -- vbuz1=vbuzz_rol_4 + // [49] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#4 << (byte) 4 -- vbuz1=vbuzz_rol_4 tza asl asl asl asl sta.z __1 - // [29] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#3 -- vbuaa=_hi_vwuz1 + // [50] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#4 -- vbuaa=_hi_vwuz1 lda.z lowerPageOffset+1 - // [30] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 + // [51] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 and #$f - // [31] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -- vbuaa=vbuz1_bor_vbuaa + // [52] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -- vbuaa=vbuz1_bor_vbuaa ora.z __1 - // [32] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 -- _deref_pbuc1=vbuaa + // [53] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 -- _deref_pbuc1=vbuaa sta xVal - // [33] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#3 -- vbuaa=_lo_vwuz1 + // [54] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperPageOffset#4 -- vbuaa=_lo_vwuz1 lda.z upperPageOffset - // [34] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 -- _deref_pbuc1=vbuaa + // [55] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 -- _deref_pbuc1=vbuaa sta yVal - // [35] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#3 & (byte) $f0 -- vbuz1=vbuzz_band_vbuc1 + // [56] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#4 & (byte) $f0 -- vbuz1=vbuzz_band_vbuc1 tza and #$f0 sta.z __6 - // [36] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#3 -- vbuaa=_hi_vwuz1 + // [57] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#4 -- vbuaa=_hi_vwuz1 lda.z upperPageOffset+1 - // [37] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 + // [58] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 and #$f - // [38] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 -- vbuaa=vbuz1_bor_vbuaa + // [59] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 -- vbuaa=vbuz1_bor_vbuaa ora.z __6 - // [39] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 -- _deref_pbuc1=vbuaa + // [60] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 -- _deref_pbuc1=vbuaa sta zVal // asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } lda aVal @@ -2000,7 +2452,7 @@ memoryRemap: { jmp __breturn // memoryRemap::@return __breturn: - // [41] return + // [62] return rts } // File Data @@ -2018,57 +2470,67 @@ MUSIC: ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __init1 Removing instruction jmp __b1 +Removing instruction jmp __breturn +Removing instruction jmp __b1 +Removing instruction jmp __b2 +Removing instruction jmp __b5 Removing instruction jmp __b3 Removing instruction jmp __b4 -Removing instruction jmp __b10 -Removing instruction jmp __b5 +Removing instruction jmp __breturn Removing instruction jmp __b6 -Removing instruction jmp __b8 -Removing instruction jmp __b9 +Removing instruction jmp __b1 +Removing instruction jmp __b3 Removing instruction jmp __b7 +Removing instruction jmp __b4 Removing instruction jmp __breturn Removing instruction jmp __breturn Succesful ASM optimization Pass5NextJumpElimination Removing instruction lda #>0 Removing instruction lda #<0 Removing instruction lda #>0 -Replacing instruction ldy #0 with TAY +Removing instruction lda #>0 +Removing instruction lda #<0 +Removing instruction lda #>0 Removing instruction lda #>0 Removing instruction lda #<0 Removing instruction lda #>0 Removing instruction ldy #0 Succesful ASM optimization Pass5UnnecesaryLoadElimination -Replacing label __b10_from___b4 with __b10 -Replacing label __b10_from___b4 with __b10 -Replacing label __b5_from___b5 with __b10 -Removing instruction __b10_from___b4: -Removing instruction __b5_from___b10: -Removing instruction __b5_from___b5: +Removing instruction __b1_from___init1: +Removing instruction __b4_from___b7: Succesful ASM optimization Pass5RedundantLabelElimination -Removing instruction memoryRemapBlock_from_main: -Removing instruction __b1_from_main: -Removing instruction __b3: -Removing instruction memoryRemap_from___b3: -Removing instruction __b4_from___b3: -Removing instruction __b5_from___b4: +Removing instruction __init1: +Removing instruction __b1: +Removing instruction __breturn: +Removing instruction __b2: +Removing instruction memoryRemapBlock_from___b2: +Removing instruction __b5: +Removing instruction memoryRemap_from___b5: +Removing instruction __b4: +Removing instruction __breturn: +Removing instruction memoryRemap_from_main: Removing instruction __b6: Removing instruction memoryRemapBlock_from___b6: -Removing instruction __b8: -Removing instruction memoryRemap_from___b8: -Removing instruction __b9: -Removing instruction __b4_from___b7: +Removing instruction __b1_from___b6: +Removing instruction __b3: +Removing instruction memoryRemap_from___b3: +Removing instruction __b7: +Removing instruction __b4_from___b4: +Removing instruction __b4_from___b5: Removing instruction __b1_from___b2: Removing instruction memoryRemap_from_memoryRemapBlock: Removing instruction __breturn: Removing instruction __breturn: Succesful ASM optimization Pass5UnusedLabelElimination -Removing instruction jmp __b5 -Succesful ASM optimization Pass5NextJumpElimination -Removing instruction __b5: -Succesful ASM optimization Pass5UnusedLabelElimination FINAL SYMBOL TABLE +(const nomodify struct MOS6526_CIA*) CIA1 = (struct MOS6526_CIA*) 56320 +(const nomodify byte) CIA_INTERRUPT_CLEAR = (byte) $7f +(const nomodify byte*) DEFAULT_SCREEN = (byte*) 2048 +(const nomodify void()**) HARDWARE_IRQ = (void()**) 65534 +(const nomodify byte) IRQ_RASTER = (byte) 1 (byte) MEGA65_VICIV::ALPHADELAY (byte) MEGA65_VICIV::B0PIX (byte) MEGA65_VICIV::B0_ADDR @@ -2357,49 +2819,71 @@ FINAL SYMBOL TABLE .fill music.size, music.getData(i) }} (const nomodify byte*) MUSIC_END = (byte*) 20992 +(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB = (byte) $31 +(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC = (byte) $54 +(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO = (byte) $5c +(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY = (byte) $2f +(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = (byte) $d (const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = (byte) $20 +(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = (byte) $11 +(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = (byte) $1a +(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = (byte) $19 (const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER = (byte) $12 +(const nomodify byte*) PROCPORT = (byte*) 1 +(const nomodify byte*) PROCPORT_DDR = (byte*) 0 +(const nomodify byte) PROCPORT_DDR_MEMORY_MASK = (byte) 7 +(const nomodify byte) PROCPORT_RAM_IO = (byte) 5 (const nomodify struct MOS6569_VICII*) VICII = (struct MOS6569_VICII*) 53248 +(const nomodify struct MOS4569_VICIII*) VICIII = (struct MOS4569_VICIII*) 53248 +(const nomodify struct MEGA65_VICIV*) VICIV = (struct MEGA65_VICIV*) 53248 +(void()) __start() +(label) __start::@1 +(label) __start::@return +(label) __start::__init1 +interrupt(HARDWARE_STACK)(void()) irq() +(label) irq::@1 +(label) irq::@2 +(label) irq::@3 +(label) irq::@4 +(label) irq::@5 +(label) irq::@return (void()) main() (label) main::@1 -(label) main::@10 (label) main::@2 (label) main::@3 (label) main::@4 (label) main::@5 (label) main::@6 (label) main::@7 -(label) main::@8 -(label) main::@9 (byte*) main::dst -(byte*) main::dst#1 dst zp[2]:2 11.0 -(byte*) main::dst#2 dst zp[2]:2 14.666666666666666 -(byte*) main::mem_destroy -(byte*) main::mem_destroy#1 mem_destroy zp[2]:6 11.0 -(byte*) main::mem_destroy#3 mem_destroy zp[2]:6 61.5 -(byte*) main::mem_destroy#5 mem_destroy zp[2]:6 39.25 +(byte*) main::dst#1 dst zp[2]:2 101.0 +(byte*) main::dst#2 dst zp[2]:2 134.66666666666666 +(byte) main::i +(byte) main::i#1 reg byte x 202.0 +(byte) main::i#2 reg byte x 468.3333333333334 (byte*) main::src -(byte*) main::src#1 src zp[2]:4 22.0 -(byte*) main::src#2 src zp[2]:4 8.25 +(byte*) main::src#1 src zp[2]:4 202.0 +(byte*) main::src#2 src zp[2]:4 75.75 +(volatile byte) mem_destroy_i loadstore zp[1]:10 5.0 (void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerPageOffset , (word) memoryRemap::upperPageOffset) (byte~) memoryRemap::$0 reg byte a 2002.0 -(byte~) memoryRemap::$1 zp[1]:12 667.3333333333334 +(byte~) memoryRemap::$1 zp[1]:11 667.3333333333334 (byte~) memoryRemap::$2 reg byte a 2002.0 (byte~) memoryRemap::$3 reg byte a 2002.0 (byte~) memoryRemap::$4 reg byte a 2002.0 (byte~) memoryRemap::$5 reg byte a 2002.0 -(byte~) memoryRemap::$6 zp[1]:13 667.3333333333334 +(byte~) memoryRemap::$6 zp[1]:12 667.3333333333334 (byte~) memoryRemap::$7 reg byte a 2002.0 (byte~) memoryRemap::$8 reg byte a 2002.0 (byte~) memoryRemap::$9 reg byte a 2002.0 (label) memoryRemap::@return (const byte*) memoryRemap::aVal = (byte*) 252 (word) memoryRemap::lowerPageOffset -(word) memoryRemap::lowerPageOffset#3 lowerPageOffset zp[2]:8 500.5 +(word) memoryRemap::lowerPageOffset#4 lowerPageOffset zp[2]:6 500.5 (byte) memoryRemap::remapBlocks -(byte) memoryRemap::remapBlocks#3 reg byte z 200.2 +(byte) memoryRemap::remapBlocks#4 reg byte z 200.2 (word) memoryRemap::upperPageOffset -(word) memoryRemap::upperPageOffset#3 upperPageOffset zp[2]:10 182.0 +(word) memoryRemap::upperPageOffset#4 upperPageOffset zp[2]:8 182.0 (const byte*) memoryRemap::xVal = (byte*) 253 (const byte*) memoryRemap::yVal = (byte*) 254 (const byte*) memoryRemap::zVal = (byte*) 255 @@ -2420,27 +2904,28 @@ FINAL SYMBOL TABLE zp[2]:2 [ main::dst#2 main::dst#1 ] zp[2]:4 [ main::src#2 main::src#1 ] -zp[2]:6 [ main::mem_destroy#3 main::mem_destroy#5 main::mem_destroy#1 ] -zp[2]:8 [ memoryRemap::lowerPageOffset#3 ] -reg byte z [ memoryRemap::remapBlocks#3 ] -zp[2]:10 [ memoryRemap::upperPageOffset#3 ] +reg byte x [ main::i#2 main::i#1 ] +zp[2]:6 [ memoryRemap::lowerPageOffset#4 ] +reg byte z [ memoryRemap::remapBlocks#4 ] +zp[2]:8 [ memoryRemap::upperPageOffset#4 ] +zp[1]:10 [ mem_destroy_i ] reg byte a [ memoryRemap::$0 ] -zp[1]:12 [ memoryRemap::$1 ] +zp[1]:11 [ memoryRemap::$1 ] reg byte a [ memoryRemap::$2 ] reg byte a [ memoryRemap::$3 ] reg byte a [ memoryRemap::$4 ] reg byte a [ memoryRemap::$5 ] -zp[1]:13 [ memoryRemap::$6 ] +zp[1]:12 [ memoryRemap::$6 ] reg byte a [ memoryRemap::$7 ] reg byte a [ memoryRemap::$8 ] reg byte a [ memoryRemap::$9 ] FINAL ASSEMBLER -Score: 4129 +Score: 2676 // File Comments -// SID music located in another bank being played using memory mapping on MEGA65 +// SID music located in another bank being played in a raster IRQ using memory mapping on the MEGA65 // Music is Cybernoid II by Jeroen Tel released in 1988 by Hewson https://csdb.dk/sid/?id=28140 // SID relocated using http://www.linusakesson.net/software/sidreloc/index.php // Upstart @@ -2457,42 +2942,214 @@ Score: 4129 .segment Basic .byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0 .byte $15, $20, $14, $00, $9e, $20 // 20 SYS -.text toIntString(main) // NNNN +.text toIntString(__start) // NNNN .byte $00, $00, $00 // // Global Constants & labels + // Value that disables all CIA interrupts when stored to the CIA Interrupt registers + .const CIA_INTERRUPT_CLEAR = $7f + // Bits for the VICII IRQ Status/Enable Registers + .const IRQ_RASTER = 1 + // Mask for PROCESSOR_PORT_DDR which allows only memory configuration to be written + .const PROCPORT_DDR_MEMORY_MASK = 7 + // RAM in 0xA000, 0xE000 I/O in 0xD000 + .const PROCPORT_RAM_IO = 5 + .const OFFSET_STRUCT_MOS4569_VICIII_KEY = $2f + .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLB = $31 + .const OFFSET_STRUCT_MEGA65_VICIV_CONTROLC = $54 + .const OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO = $5c + .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d .const OFFSET_STRUCT_MOS6569_VICII_RASTER = $12 + .const OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = $11 + .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a + .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19 .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 + // Processor port data direction register + .label PROCPORT_DDR = 0 + // Processor Port Register controlling RAM/ROM configuration and the datasette + .label PROCPORT = 1 // The VIC-II MOS 6567/6569 .label VICII = $d000 + // The VIC III MOS 4567/4569 + .label VICIII = $d000 + // The VIC IV + .label VICIV = $d000 + // Default address of screen character matrix + .label DEFAULT_SCREEN = $800 + // The CIA#1: keyboard matrix, joystick #1/#2 + .label CIA1 = $dc00 + // The vector used when the HARDWARE serves IRQ interrupts + .label HARDWARE_IRQ = $fffe // Address after the end of the music .label MUSIC_END = $5200 // Pointer to the music init routine .label musicInit = MUSIC // Pointer to the music play routine .label musicPlay = MUSIC+3 + // Index used to destroy unmapped music memory (to demonstrate that mapping works) + .label mem_destroy_i = $a .segment Code + // __start +__start: { + // __start::__init1 + // mem_destroy_i = 0 + // [1] (volatile byte) mem_destroy_i ← (byte) 0 -- vbuz1=vbuc1 + lda #0 + sta.z mem_destroy_i + // [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1] + // __start::@1 + // [3] call main + jsr main + // __start::@return + // [4] return + rts +} + // irq +// Raster IRQ routine +irq: { + // entry interrupt(HARDWARE_STACK) + pha + txa + pha + tya + pha + // VICII->IRQ_STATUS = IRQ_RASTER + // [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 + // Acknowledge the IRQ + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS + // MUSIC[mem_destroy_i++]++; + // [6] *((const byte*) MUSIC + (volatile byte) mem_destroy_i) ← ++ *((const byte*) MUSIC + (volatile byte) mem_destroy_i) -- pbuc1_derefidx_vbuz1=_inc_pbuc1_derefidx_vbuz1 + ldx.z mem_destroy_i + inc MUSIC,x + // [7] (volatile byte) mem_destroy_i ← ++ (volatile byte) mem_destroy_i -- vbuz1=_inc_vbuz1 + inc.z mem_destroy_i + // Wait for the raster + // irq::@1 + __b1: + // while(VICII->RASTER!=0xff) + // [8] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto irq::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 + lda #$ff + cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + bne __b1 + // irq::@2 + // (VICII->BORDER_COLOR)++; + // [9] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1 + inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + // memoryRemapBlock(0x40, 0x100) + // [10] call memoryRemapBlock + // Remap memory to put music at $4000 + // [43] phi from irq::@2 to memoryRemapBlock [phi:irq::@2->memoryRemapBlock] + jsr memoryRemapBlock + // irq::@5 + // (*musicPlay)() + // [11] call *((const void()*) musicPlay) + // Play remapped SID + jsr musicPlay + // memoryRemap(0,0,0) + // [12] call memoryRemap + // Reset memory mapping + // [46] phi from irq::@5 to memoryRemap [phi:irq::@5->memoryRemap] + // [46] phi (word) memoryRemap::upperPageOffset#4 = (byte) 0 [phi:irq::@5->memoryRemap#0] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.upperPageOffset + sta.z memoryRemap.upperPageOffset+1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (byte) 0 [phi:irq::@5->memoryRemap#1] -- vbuzz=vbuc1 + ldz #0 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (byte) 0 [phi:irq::@5->memoryRemap#2] -- vwuz1=vbuc1 + sta.z memoryRemap.lowerPageOffset + sta.z memoryRemap.lowerPageOffset+1 + jsr memoryRemap + // Wait for the raster + // irq::@3 + __b3: + // while(VICII->RASTER==0xff) + // [13] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto irq::@3 -- _deref_pbuc1_eq_vbuc2_then_la1 + lda #$ff + cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + beq __b3 + // irq::@4 + // (VICII->BORDER_COLOR)--; + // [14] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1 + dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + // irq::@return + // } + // [15] return - exit interrupt(HARDWARE_STACK) + pla + tay + pla + tax + pla + rti +} // main main: { .label dst = 2 .label src = 4 - // Pointer to (unmapped) $4000 used for overwriting to demonstrate the mapping works - .label mem_destroy = 6 // asm // asm { sei } // Stop IRQ's sei + // memoryRemap(0,0,0) + // [17] call memoryRemap + // Map memory to BANK 0 : 0x00XXXX - giving access to I/O + // [46] phi from main to memoryRemap [phi:main->memoryRemap] + // [46] phi (word) memoryRemap::upperPageOffset#4 = (byte) 0 [phi:main->memoryRemap#0] -- vwuz1=vbuc1 + lda #<0 + sta.z memoryRemap.upperPageOffset + sta.z memoryRemap.upperPageOffset+1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (byte) 0 [phi:main->memoryRemap#1] -- vbuzz=vbuc1 + ldz #0 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (byte) 0 [phi:main->memoryRemap#2] -- vwuz1=vbuc1 + sta.z memoryRemap.lowerPageOffset + sta.z memoryRemap.lowerPageOffset+1 + jsr memoryRemap + // main::@6 + // VICIII->KEY = 0x47 + // [18] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $47 -- _deref_pbuc1=vbuc2 + // Enable MEGA65 features + lda #$47 + sta VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY + // VICIII->KEY = 0x53 + // [19] *((byte*)(const nomodify struct MOS4569_VICIII*) VICIII+(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY) ← (byte) $53 -- _deref_pbuc1=vbuc2 + lda #$53 + sta VICIII+OFFSET_STRUCT_MOS4569_VICIII_KEY + // VICIV->CONTROLB |= 0x40 + // [20] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB) | (byte) $40 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2 + // Enable 48MHz fast mode + lda #$40 + ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLB + // VICIV->CONTROLC |= 0x40 + // [21] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) ← *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC) | (byte) $40 -- _deref_pbuc1=_deref_pbuc1_bor_vbuc2 + lda #$40 + ora VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_CONTROLC + // *PROCPORT_DDR = PROCPORT_DDR_MEMORY_MASK + // [22] *((const nomodify byte*) PROCPORT_DDR) ← (const nomodify byte) PROCPORT_DDR_MEMORY_MASK -- _deref_pbuc1=vbuc2 + // no kernal or BASIC rom visible + lda #PROCPORT_DDR_MEMORY_MASK + sta PROCPORT_DDR + // *PROCPORT = PROCPORT_RAM_IO + // [23] *((const nomodify byte*) PROCPORT) ← (const nomodify byte) PROCPORT_RAM_IO -- _deref_pbuc1=vbuc2 + lda #PROCPORT_RAM_IO + sta PROCPORT + // VICIV->SIDBDRWD_LO = 1 + // [24] *((byte*)(const nomodify struct MEGA65_VICIV*) VICIV+(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO) ← (byte) 1 -- _deref_pbuc1=vbuc2 + // open sideborder + lda #1 + sta VICIV+OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO // memoryRemapBlock(0x40, 0x100) - // [1] call memoryRemapBlock + // [25] call memoryRemapBlock // Remap [$4000-$5fff] to point to [$10000-$11fff] - // [22] phi from main to memoryRemapBlock [phi:main->memoryRemapBlock] + // [43] phi from main::@6 to memoryRemapBlock [phi:main::@6->memoryRemapBlock] jsr memoryRemapBlock - // [2] phi from main to main::@1 [phi:main->main::@1] - // [2] phi (byte*) main::src#2 = (const byte*) upperCodeData [phi:main->main::@1#0] -- pbuz1=pbuc1 + // [26] phi from main::@6 to main::@1 [phi:main::@6->main::@1] + // [26] phi (byte*) main::src#2 = (const byte*) upperCodeData [phi:main::@6->main::@1#0] -- pbuz1=pbuc1 lda #upperCodeData sta.z src+1 - // [2] phi (byte*) main::dst#2 = (const byte*) MUSIC [phi:main->main::@1#1] -- pbuz1=pbuc1 + // [26] phi (byte*) main::dst#2 = (const byte*) MUSIC [phi:main::@6->main::@1#1] -- pbuz1=pbuc1 lda #MUSIC @@ -2501,7 +3158,7 @@ main: { // main::@1 __b1: // for( char *src=upperCodeData, *dst=MUSIC; dstMUSIC_END bcc __b2 @@ -2512,123 +3169,94 @@ main: { !: // main::@3 // (*musicInit)() - // [4] call *((const void()*) musicInit) + // [28] call *((const void()*) musicInit) // Initialize SID memory is still remapped) jsr musicInit // memoryRemap(0,0,0) - // [5] call memoryRemap + // [29] call memoryRemap // Reset memory mapping - // [25] phi from main::@3 to memoryRemap [phi:main::@3->memoryRemap] - // [25] phi (word) memoryRemap::upperPageOffset#3 = (byte) 0 [phi:main::@3->memoryRemap#0] -- vwuz1=vbuc1 + // [46] phi from main::@3 to memoryRemap [phi:main::@3->memoryRemap] + // [46] phi (word) memoryRemap::upperPageOffset#4 = (byte) 0 [phi:main::@3->memoryRemap#0] -- vwuz1=vbuc1 lda #<0 sta.z memoryRemap.upperPageOffset sta.z memoryRemap.upperPageOffset+1 - // [25] phi (byte) memoryRemap::remapBlocks#3 = (byte) 0 [phi:main::@3->memoryRemap#1] -- vbuzz=vbuc1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (byte) 0 [phi:main::@3->memoryRemap#1] -- vbuzz=vbuc1 ldz #0 - // [25] phi (word) memoryRemap::lowerPageOffset#3 = (byte) 0 [phi:main::@3->memoryRemap#2] -- vwuz1=vbuc1 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (byte) 0 [phi:main::@3->memoryRemap#2] -- vwuz1=vbuc1 sta.z memoryRemap.lowerPageOffset sta.z memoryRemap.lowerPageOffset+1 jsr memoryRemap - // [6] phi from main::@3 to main::@4 [phi:main::@3->main::@4] - // [6] phi (byte*) main::mem_destroy#3 = (const byte*) MUSIC [phi:main::@3->main::@4#0] -- pbuz1=pbuc1 - lda #MUSIC - sta.z mem_destroy+1 + // main::@7 + // CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR + // [30] *((byte*)(const nomodify struct MOS6526_CIA*) CIA1+(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT) ← (const nomodify byte) CIA_INTERRUPT_CLEAR -- _deref_pbuc1=vbuc2 + // Set up raster interrupts C64 style + // Disable CIA 1 Timer IRQ + lda #CIA_INTERRUPT_CLEAR + sta CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT + // VICII->RASTER = 0xff + // [31] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER) ← (byte) $ff -- _deref_pbuc1=vbuc2 + // Set raster line to 0xff + lda #$ff + sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + // VICII->CONTROL1 &= 0x7f + // [32] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) ← *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1) & (byte) $7f -- _deref_pbuc1=_deref_pbuc1_band_vbuc2 + lda #$7f + and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + // VICII->IRQ_ENABLE = IRQ_RASTER + // [33] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE) ← (const nomodify byte) IRQ_RASTER -- _deref_pbuc1=vbuc2 + // Enable Raster Interrupt + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE + // *HARDWARE_IRQ = &irq + // [34] *((const nomodify void()**) HARDWARE_IRQ) ← &interrupt(HARDWARE_STACK)(void()) irq() -- _deref_qprc1=pprc2 + // Set the IRQ routine + lda #irq + sta HARDWARE_IRQ+1 + // asm + // asm { cli } + // Enable IRQ + cli + // [36] phi from main::@7 to main::@4 [phi:main::@7->main::@4] // main::@4 __b4: - // *mem_destroy = 0 - // [7] *((byte*) main::mem_destroy#3) ← (byte) 0 -- _deref_pbuz1=vbuc1 - // Overwrite data in the unmapped memory where the music is mapped in (to demonstrate that mapping works) - lda #0 - tay - sta (mem_destroy),y - // if(++mem_destroy==MUSIC_END) - // [8] (byte*) main::mem_destroy#1 ← ++ (byte*) main::mem_destroy#3 -- pbuz1=_inc_pbuz1 - inw.z mem_destroy - // [9] if((byte*) main::mem_destroy#1!=(const nomodify byte*) MUSIC_END) goto main::@10 -- pbuz1_neq_pbuc1_then_la1 - lda.z mem_destroy+1 - cmp #>MUSIC_END - bne __b10 - lda.z mem_destroy - cmp #main::@5] - // [11] phi (byte*) main::mem_destroy#5 = (const byte*) MUSIC [phi:main::@4->main::@5#0] -- pbuz1=pbuc1 - lda #MUSIC - sta.z mem_destroy+1 - // [10] phi from main::@4 to main::@10 [phi:main::@4->main::@10] - // main::@10 - __b10: - // [11] phi from main::@10 main::@5 to main::@5 [phi:main::@10/main::@5->main::@5] - // [11] phi (byte*) main::mem_destroy#5 = (byte*) main::mem_destroy#1 [phi:main::@10/main::@5->main::@5#0] -- register_copy - // Wait for the raster + // for(char i=0;i<240;i++) + // [37] if((byte) main::i#2<(byte) $f0) goto main::@5 -- vbuxx_lt_vbuc1_then_la1 + cpx #$f0 + bcc __b5 + // [36] phi from main::@4 to main::@4 [phi:main::@4->main::@4] + // [36] phi (byte) main::i#2 = (byte) 0 [phi:main::@4->main::@4#0] -- vbuxx=vbuc1 + ldx #0 + jmp __b4 // main::@5 - // while(VICII->RASTER!=0xff) - // [12] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)!=(byte) $ff) goto main::@5 -- _deref_pbuc1_neq_vbuc2_then_la1 - lda #$ff - cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER - bne __b10 - // main::@6 - // (VICII->BORDER_COLOR)++; - // [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← ++ *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_inc__deref_pbuc1 - inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - // memoryRemapBlock(0x40, 0x100) - // [14] call memoryRemapBlock - // Remap memory to put music at $4000 - // [22] phi from main::@6 to memoryRemapBlock [phi:main::@6->memoryRemapBlock] - jsr memoryRemapBlock - // main::@8 - // (*musicPlay)() - // [15] call *((const void()*) musicPlay) - // Play remapped SID - jsr musicPlay - // memoryRemap(0,0,0) - // [16] call memoryRemap - // Reset memory mapping - // [25] phi from main::@8 to memoryRemap [phi:main::@8->memoryRemap] - // [25] phi (word) memoryRemap::upperPageOffset#3 = (byte) 0 [phi:main::@8->memoryRemap#0] -- vwuz1=vbuc1 - lda #<0 - sta.z memoryRemap.upperPageOffset - sta.z memoryRemap.upperPageOffset+1 - // [25] phi (byte) memoryRemap::remapBlocks#3 = (byte) 0 [phi:main::@8->memoryRemap#1] -- vbuzz=vbuc1 - ldz #0 - // [25] phi (word) memoryRemap::lowerPageOffset#3 = (byte) 0 [phi:main::@8->memoryRemap#2] -- vwuz1=vbuc1 - sta.z memoryRemap.lowerPageOffset - sta.z memoryRemap.lowerPageOffset+1 - jsr memoryRemap - // main::@9 - // (VICII->BORDER_COLOR)--; - // [17] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← -- *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) -- _deref_pbuc1=_dec__deref_pbuc1 - dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - // Wait for the raster - // main::@7 - __b7: - // while(VICII->RASTER==0xff) - // [18] if(*((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER)==(byte) $ff) goto main::@7 -- _deref_pbuc1_eq_vbuc2_then_la1 - lda #$ff - cmp VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER - beq __b7 - // [6] phi from main::@7 to main::@4 [phi:main::@7->main::@4] - // [6] phi (byte*) main::mem_destroy#3 = (byte*) main::mem_destroy#5 [phi:main::@7->main::@4#0] -- register_copy + __b5: + // DEFAULT_SCREEN[i] = MUSIC[i] + // [38] *((const nomodify byte*) DEFAULT_SCREEN + (byte) main::i#2) ← *((const byte*) MUSIC + (byte) main::i#2) -- pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx + lda MUSIC,x + sta DEFAULT_SCREEN,x + // for(char i=0;i<240;i++) + // [39] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx + inx + // [36] phi from main::@5 to main::@4 [phi:main::@5->main::@4] + // [36] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@4#0] -- register_copy jmp __b4 // main::@2 __b2: // *dst++ = *src++ - // [19] *((byte*) main::dst#2) ← *((byte*) main::src#2) -- _deref_pbuz1=_deref_pbuz2 + // [40] *((byte*) main::dst#2) ← *((byte*) main::src#2) -- _deref_pbuz1=_deref_pbuz2 ldy #0 lda (src),y sta (dst),y // *dst++ = *src++; - // [20] (byte*) main::dst#1 ← ++ (byte*) main::dst#2 -- pbuz1=_inc_pbuz1 + // [41] (byte*) main::dst#1 ← ++ (byte*) main::dst#2 -- pbuz1=_inc_pbuz1 inw.z dst - // [21] (byte*) main::src#1 ← ++ (byte*) main::src#2 -- pbuz1=_inc_pbuz1 + // [42] (byte*) main::src#1 ← ++ (byte*) main::src#2 -- pbuz1=_inc_pbuz1 inw.z src - // [2] phi from main::@2 to main::@1 [phi:main::@2->main::@1] - // [2] phi (byte*) main::src#2 = (byte*) main::src#1 [phi:main::@2->main::@1#0] -- register_copy - // [2] phi (byte*) main::dst#2 = (byte*) main::dst#1 [phi:main::@2->main::@1#1] -- register_copy + // [26] phi from main::@2 to main::@1 [phi:main::@2->main::@1] + // [26] phi (byte*) main::src#2 = (byte*) main::src#1 [phi:main::@2->main::@1#0] -- register_copy + // [26] phi (byte*) main::dst#2 = (byte*) main::dst#1 [phi:main::@2->main::@1#1] -- register_copy jmp __b1 } // memoryRemapBlock @@ -2642,16 +3270,16 @@ memoryRemapBlock: { .const block = $40>>5 .const blockBits = 1<memoryRemap] - // [25] phi (word) memoryRemap::upperPageOffset#3 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#0] -- vwuz1=vwuc1 + // [44] call memoryRemap + // [46] phi from memoryRemapBlock to memoryRemap [phi:memoryRemapBlock->memoryRemap] + // [46] phi (word) memoryRemap::upperPageOffset#4 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#0] -- vwuz1=vwuc1 lda #pageOffset sta.z memoryRemap.upperPageOffset+1 - // [25] phi (byte) memoryRemap::remapBlocks#3 = (const byte) memoryRemapBlock::blockBits#0 [phi:memoryRemapBlock->memoryRemap#1] -- vbuzz=vbuc1 + // [46] phi (byte) memoryRemap::remapBlocks#4 = (const byte) memoryRemapBlock::blockBits#0 [phi:memoryRemapBlock->memoryRemap#1] -- vbuzz=vbuc1 ldz #blockBits - // [25] phi (word) memoryRemap::lowerPageOffset#3 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#2] -- vwuz1=vwuc1 + // [46] phi (word) memoryRemap::lowerPageOffset#4 = (const word) memoryRemapBlock::pageOffset#0 [phi:memoryRemapBlock->memoryRemap#2] -- vwuz1=vwuc1 lda #pageOffset @@ -2659,7 +3287,7 @@ memoryRemapBlock: { jsr memoryRemap // memoryRemapBlock::@return // } - // [24] return + // [45] return rts } // memoryRemap @@ -2687,24 +3315,24 @@ memoryRemapBlock: { // - If block 5 ($a000-$bfff) is remapped it will point to upperPageOffset*$100 + $a000. // - If block 6 ($c000-$dfff) is remapped it will point to upperPageOffset*$100 + $c000. // - If block 7 ($e000-$ffff) is remapped it will point to upperPageOffset*$100 + $e000. -// memoryRemap(byte register(Z) remapBlocks, word zp(8) lowerPageOffset, word zp($a) upperPageOffset) +// memoryRemap(byte register(Z) remapBlocks, word zp(6) lowerPageOffset, word zp(8) upperPageOffset) memoryRemap: { .label aVal = $fc .label xVal = $fd .label yVal = $fe .label zVal = $ff - .label __1 = $c - .label __6 = $d - .label lowerPageOffset = 8 - .label upperPageOffset = $a + .label __1 = $b + .label __6 = $c + .label lowerPageOffset = 6 + .label upperPageOffset = 8 // lowerPageOffset - // [29] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#3 -- vbuaa=_hi_vwuz1 + // [50] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerPageOffset#4 -- vbuaa=_hi_vwuz1 lda.z lowerPageOffset+1 // >lowerPageOffset & 0xf - // [30] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 + // [51] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 and #$f // (remapBlocks << 4) | (>lowerPageOffset & 0xf) - // [31] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -- vbuaa=vbuz1_bor_vbuaa + // [52] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -- vbuaa=vbuz1_bor_vbuaa ora.z __1 // *xVal = (remapBlocks << 4) | (>lowerPageOffset & 0xf) - // [32] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 -- _deref_pbuc1=vbuaa + // [53] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 -- _deref_pbuc1=vbuaa sta xVal // upperPageOffset - // [36] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#3 -- vbuaa=_hi_vwuz1 + // [57] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperPageOffset#4 -- vbuaa=_hi_vwuz1 lda.z upperPageOffset+1 // >upperPageOffset & 0xf - // [37] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 + // [58] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 and #$f // (remapBlocks & 0xf0) | (>upperPageOffset & 0xf) - // [38] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 -- vbuaa=vbuz1_bor_vbuaa + // [59] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 -- vbuaa=vbuz1_bor_vbuaa ora.z __6 // *zVal = (remapBlocks & 0xf0) | (>upperPageOffset & 0xf) - // [39] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 -- _deref_pbuc1=vbuaa + // [60] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 -- _deref_pbuc1=vbuaa sta zVal // asm // asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } @@ -2756,7 +3384,7 @@ memoryRemap: { eom // memoryRemap::@return // } - // [41] return + // [62] return rts } // File Data diff --git a/src/test/ref/examples/mega65/banked-music.sym b/src/test/ref/examples/mega65/banked-music.sym index 5223a67e6..9e4ed3ab0 100644 --- a/src/test/ref/examples/mega65/banked-music.sym +++ b/src/test/ref/examples/mega65/banked-music.sym @@ -1,3 +1,8 @@ +(const nomodify struct MOS6526_CIA*) CIA1 = (struct MOS6526_CIA*) 56320 +(const nomodify byte) CIA_INTERRUPT_CLEAR = (byte) $7f +(const nomodify byte*) DEFAULT_SCREEN = (byte*) 2048 +(const nomodify void()**) HARDWARE_IRQ = (void()**) 65534 +(const nomodify byte) IRQ_RASTER = (byte) 1 (byte) MEGA65_VICIV::ALPHADELAY (byte) MEGA65_VICIV::B0PIX (byte) MEGA65_VICIV::B0_ADDR @@ -286,49 +291,71 @@ .fill music.size, music.getData(i) }} (const nomodify byte*) MUSIC_END = (byte*) 20992 +(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLB = (byte) $31 +(const byte) OFFSET_STRUCT_MEGA65_VICIV_CONTROLC = (byte) $54 +(const byte) OFFSET_STRUCT_MEGA65_VICIV_SIDBDRWD_LO = (byte) $5c +(const byte) OFFSET_STRUCT_MOS4569_VICIII_KEY = (byte) $2f +(const byte) OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = (byte) $d (const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = (byte) $20 +(const byte) OFFSET_STRUCT_MOS6569_VICII_CONTROL1 = (byte) $11 +(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = (byte) $1a +(const byte) OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = (byte) $19 (const byte) OFFSET_STRUCT_MOS6569_VICII_RASTER = (byte) $12 +(const nomodify byte*) PROCPORT = (byte*) 1 +(const nomodify byte*) PROCPORT_DDR = (byte*) 0 +(const nomodify byte) PROCPORT_DDR_MEMORY_MASK = (byte) 7 +(const nomodify byte) PROCPORT_RAM_IO = (byte) 5 (const nomodify struct MOS6569_VICII*) VICII = (struct MOS6569_VICII*) 53248 +(const nomodify struct MOS4569_VICIII*) VICIII = (struct MOS4569_VICIII*) 53248 +(const nomodify struct MEGA65_VICIV*) VICIV = (struct MEGA65_VICIV*) 53248 +(void()) __start() +(label) __start::@1 +(label) __start::@return +(label) __start::__init1 +interrupt(HARDWARE_STACK)(void()) irq() +(label) irq::@1 +(label) irq::@2 +(label) irq::@3 +(label) irq::@4 +(label) irq::@5 +(label) irq::@return (void()) main() (label) main::@1 -(label) main::@10 (label) main::@2 (label) main::@3 (label) main::@4 (label) main::@5 (label) main::@6 (label) main::@7 -(label) main::@8 -(label) main::@9 (byte*) main::dst -(byte*) main::dst#1 dst zp[2]:2 11.0 -(byte*) main::dst#2 dst zp[2]:2 14.666666666666666 -(byte*) main::mem_destroy -(byte*) main::mem_destroy#1 mem_destroy zp[2]:6 11.0 -(byte*) main::mem_destroy#3 mem_destroy zp[2]:6 61.5 -(byte*) main::mem_destroy#5 mem_destroy zp[2]:6 39.25 +(byte*) main::dst#1 dst zp[2]:2 101.0 +(byte*) main::dst#2 dst zp[2]:2 134.66666666666666 +(byte) main::i +(byte) main::i#1 reg byte x 202.0 +(byte) main::i#2 reg byte x 468.3333333333334 (byte*) main::src -(byte*) main::src#1 src zp[2]:4 22.0 -(byte*) main::src#2 src zp[2]:4 8.25 +(byte*) main::src#1 src zp[2]:4 202.0 +(byte*) main::src#2 src zp[2]:4 75.75 +(volatile byte) mem_destroy_i loadstore zp[1]:10 5.0 (void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerPageOffset , (word) memoryRemap::upperPageOffset) (byte~) memoryRemap::$0 reg byte a 2002.0 -(byte~) memoryRemap::$1 zp[1]:12 667.3333333333334 +(byte~) memoryRemap::$1 zp[1]:11 667.3333333333334 (byte~) memoryRemap::$2 reg byte a 2002.0 (byte~) memoryRemap::$3 reg byte a 2002.0 (byte~) memoryRemap::$4 reg byte a 2002.0 (byte~) memoryRemap::$5 reg byte a 2002.0 -(byte~) memoryRemap::$6 zp[1]:13 667.3333333333334 +(byte~) memoryRemap::$6 zp[1]:12 667.3333333333334 (byte~) memoryRemap::$7 reg byte a 2002.0 (byte~) memoryRemap::$8 reg byte a 2002.0 (byte~) memoryRemap::$9 reg byte a 2002.0 (label) memoryRemap::@return (const byte*) memoryRemap::aVal = (byte*) 252 (word) memoryRemap::lowerPageOffset -(word) memoryRemap::lowerPageOffset#3 lowerPageOffset zp[2]:8 500.5 +(word) memoryRemap::lowerPageOffset#4 lowerPageOffset zp[2]:6 500.5 (byte) memoryRemap::remapBlocks -(byte) memoryRemap::remapBlocks#3 reg byte z 200.2 +(byte) memoryRemap::remapBlocks#4 reg byte z 200.2 (word) memoryRemap::upperPageOffset -(word) memoryRemap::upperPageOffset#3 upperPageOffset zp[2]:10 182.0 +(word) memoryRemap::upperPageOffset#4 upperPageOffset zp[2]:8 182.0 (const byte*) memoryRemap::xVal = (byte*) 253 (const byte*) memoryRemap::yVal = (byte*) 254 (const byte*) memoryRemap::zVal = (byte*) 255 @@ -349,17 +376,18 @@ zp[2]:2 [ main::dst#2 main::dst#1 ] zp[2]:4 [ main::src#2 main::src#1 ] -zp[2]:6 [ main::mem_destroy#3 main::mem_destroy#5 main::mem_destroy#1 ] -zp[2]:8 [ memoryRemap::lowerPageOffset#3 ] -reg byte z [ memoryRemap::remapBlocks#3 ] -zp[2]:10 [ memoryRemap::upperPageOffset#3 ] +reg byte x [ main::i#2 main::i#1 ] +zp[2]:6 [ memoryRemap::lowerPageOffset#4 ] +reg byte z [ memoryRemap::remapBlocks#4 ] +zp[2]:8 [ memoryRemap::upperPageOffset#4 ] +zp[1]:10 [ mem_destroy_i ] reg byte a [ memoryRemap::$0 ] -zp[1]:12 [ memoryRemap::$1 ] +zp[1]:11 [ memoryRemap::$1 ] reg byte a [ memoryRemap::$2 ] reg byte a [ memoryRemap::$3 ] reg byte a [ memoryRemap::$4 ] reg byte a [ memoryRemap::$5 ] -zp[1]:13 [ memoryRemap::$6 ] +zp[1]:12 [ memoryRemap::$6 ] reg byte a [ memoryRemap::$7 ] reg byte a [ memoryRemap::$8 ] reg byte a [ memoryRemap::$9 ]