1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-23 13:31:12 +00:00

Extended sprite CX16 example. #581

This commit is contained in:
jespergravgaard 2020-12-17 09:26:34 +01:00
parent dbaea05623
commit e4349daaf6
5 changed files with 1682 additions and 666 deletions

View File

@ -1,5 +1,5 @@
// Example program for the Commander X16
// Displays a sprite
// Displays some sprites - exceeding the per-line limits of the CX16
#pragma target(cx16)
#include <cx16.h>
@ -13,12 +13,41 @@ align(0x100) char SPRITE_PIXELS[64*64] = kickasm(resource "sprite.png") {{
.byte (pic.getPixel(x,y)==0) ? 0 : 1
}};
#define NUM_SPRITES 128
// Address to use for sprite pixels in VRAM
const unsigned long SPRITE_PIXELS_VRAM = 0x08000;
// Sprite attributes: 8bpp, in front, 64x64, address SPRITE_PIXELS_VRAM
struct VERA_SPRITE SPRITE_ATTR = { <(SPRITE_PIXELS_VRAM/32)|VERA_SPRITE_8BPP, 320-32, 240-32, 0x0c, 0xf0 };
void main() {
// Copy sprite data to VRAM
memcpy_to_vram((char)>SPRITE_PIXELS_VRAM, <SPRITE_PIXELS_VRAM, SPRITE_PIXELS, sizeof(SPRITE_PIXELS));
// Copy 8* sprite attributes to VRAM
char* vram_sprite_attr = <VERA_SPRITE_ATTR;
for(char s=0;s<NUM_SPRITES;s++) {
SPRITE_ATTR.X += 10;
SPRITE_ATTR.Y += 10;
memcpy_to_vram((char)>VERA_SPRITE_ATTR, vram_sprite_attr, &SPRITE_ATTR, sizeof(SPRITE_ATTR));
vram_sprite_attr += sizeof(SPRITE_ATTR);
}
// Makea border
//*VERA_CTRL |= VERA_DCSEL;
//*VERA_DC_HSTART = 16/4;
//*VERA_DC_HSTOP = 624/4;
//*VERA_DC_VSTART = 16/2;
//*VERA_DC_VSTOP = 464/2;
// Enable sprites
*VERA_CTRL &= ~VERA_DCSEL;
*VERA_DC_VIDEO |= VERA_SPRITES_ENABLE;
// Enable VSYNC IRQ (also set line bit 8 to 0)
SEI();
*KERNEL_IRQ = &irq_vsync;
*VERA_IEN = VERA_VSYNC;
CLI();
}
// X sine [0;640-64]
align(0x100) unsigned int SINX[241] = kickasm {{
.fillword 256, 288+288*sin(i*2*PI/241)
@ -29,21 +58,6 @@ align(0x100) unsigned int SINY[251] = kickasm {{
.fillword 256, 208+208*sin(i*2*PI/251)
}};
void main() {
// Copy sprite data to VRAM
memcpy_to_vram((char)>SPRITE_PIXELS_VRAM, <SPRITE_PIXELS_VRAM, SPRITE_PIXELS, sizeof(SPRITE_PIXELS));
// Copy sprite attributes to VRAM
memcpy_to_vram((char)>VERA_SPRITE_ATTR, <VERA_SPRITE_ATTR, &SPRITE_ATTR, sizeof(SPRITE_ATTR));
// Enable sprites
*VERA_CTRL &= ~VERA_DCSEL;
*VERA_DC_VIDEO |= VERA_SPRITES_ENABLE;
// Enable VSYNC IRQ (also set line bit 8 to 0)
SEI();
*KERNEL_IRQ = &irq_vsync;
*VERA_IEN = VERA_VSYNC;
CLI();
}
// X sine index
volatile unsigned int sin_idx_x = 119;
// Y sine index
@ -51,13 +65,28 @@ volatile unsigned int sin_idx_y = 79;
// VSYNC Interrupt Routine
void irq_vsync() {
// Color border
//*VERA_CTRL &= ~VERA_DCSEL;
//*VERA_DC_BORDER = 2;
// Move the sprite around
if(++sin_idx_x==241) sin_idx_x = 0;
if(--sin_idx_y==0xffff) sin_idx_y = 251-1;
SPRITE_ATTR.X = SINX[sin_idx_x];
SPRITE_ATTR.Y = SINY[sin_idx_y];
// Copy sprite positions to VRAM (the 4 relevant bytes in VERA_SPRITE_ATTR)
memcpy_to_vram((char)>VERA_SPRITE_ATTR, <VERA_SPRITE_ATTR+2, &SPRITE_ATTR+2, 4);
const char vram_sprite_attr_bank = (char)>VERA_SPRITE_ATTR;
char *vram_sprite_pos = <VERA_SPRITE_ATTR+2;
unsigned int i_x = sin_idx_x;
unsigned int i_y = sin_idx_y;
for(char s=0;s<NUM_SPRITES;s++) {
SPRITE_ATTR.X = SINX[i_x];
SPRITE_ATTR.Y = SINY[i_y];
// Copy sprite positions to VRAM (the 4 relevant bytes in VERA_SPRITE_ATTR)
memcpy_to_vram(vram_sprite_attr_bank, vram_sprite_pos, &SPRITE_ATTR+2, 4);
vram_sprite_pos += sizeof(SPRITE_ATTR);
i_x += 3; if(i_x>=241) i_x -= 241;
i_y += 5; if(i_y>=251) i_y -= 251;
}
// Black border
//*VERA_CTRL &= ~VERA_DCSEL;
//*VERA_DC_BORDER = 0;
// Reset the VSYNC interrupt
*VERA_ISR = VERA_VSYNC;
// Exit CX16 KERNAL IRQ

View File

@ -1,5 +1,5 @@
// Example program for the Commander X16
// Displays a sprite
// Displays some sprites - exceeding the per-line limits of the CX16
.cpu _65c02
// Commodore 64 PRG executable file
.file [name="sprite.prg", type="prg", segments="Program"]
@ -71,9 +71,9 @@
// $0314 (RAM) IRQ vector - The vector used when the KERNAL serves IRQ interrupts
.label KERNEL_IRQ = $314
// X sine index
.label sin_idx_x = 8
.label sin_idx_x = $12
// Y sine index
.label sin_idx_y = $a
.label sin_idx_y = $14
.segment Code
__start: {
// sin_idx_x = 119
@ -91,10 +91,15 @@ __start: {
}
// VSYNC Interrupt Routine
irq_vsync: {
.label __5 = $c
.label __6 = $e
.label __7 = $c
.label __8 = $e
.const vram_sprite_attr_bank = VERA_SPRITE_ATTR>>$10
.label __11 = $16
.label __12 = $18
.label i_x = 3
.label i_y = 5
.label vram_sprite_pos = 7
.label s = 2
.label __13 = $16
.label __14 = $18
// if(++sin_idx_x==241)
inc.z sin_idx_x
bne !+
@ -129,47 +134,84 @@ irq_vsync: {
lda #>$fb-1
sta.z sin_idx_y+1
__b2:
// SPRITE_ATTR.X = SINX[sin_idx_x]
// i_x = sin_idx_x
lda.z sin_idx_x
asl
sta.z __5
sta.z i_x
lda.z sin_idx_x+1
sta.z i_x+1
// i_y = sin_idx_y
lda.z sin_idx_y
sta.z i_y
lda.z sin_idx_y+1
sta.z i_y+1
lda #<VERA_SPRITE_ATTR+2&$ffff
sta.z vram_sprite_pos
lda #>VERA_SPRITE_ATTR+2&$ffff
sta.z vram_sprite_pos+1
lda #0
sta.z s
__b5:
// for(char s=0;s<NUM_SPRITES;s++)
lda.z s
cmp #$80
bcc __b6
// *VERA_ISR = VERA_VSYNC
// Black border
//*VERA_CTRL &= ~VERA_DCSEL;
//*VERA_DC_BORDER = 0;
// Reset the VSYNC interrupt
lda #VERA_VSYNC
sta VERA_ISR
// asm
// Exit CX16 KERNAL IRQ
jmp $e034
// }
__b6:
// SPRITE_ATTR.X = SINX[i_x]
lda.z i_x
asl
sta.z __11
lda.z i_x+1
rol
sta.z __5+1
sta.z __11+1
clc
lda.z __7
lda.z __13
adc #<SINX
sta.z __7
lda.z __7+1
sta.z __13
lda.z __13+1
adc #>SINX
sta.z __7+1
sta.z __13+1
ldy #0
lda (__7),y
lda (__13),y
sta SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X
iny
lda (__7),y
lda (__13),y
sta SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X+1
// SPRITE_ATTR.Y = SINY[sin_idx_y]
lda.z sin_idx_y
// SPRITE_ATTR.Y = SINY[i_y]
lda.z i_y
asl
sta.z __6
lda.z sin_idx_y+1
sta.z __12
lda.z i_y+1
rol
sta.z __6+1
sta.z __12+1
clc
lda.z __8
lda.z __14
adc #<SINY
sta.z __8
lda.z __8+1
sta.z __14
lda.z __14+1
adc #>SINY
sta.z __8+1
sta.z __14+1
ldy #0
lda (__8),y
lda (__14),y
sta SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y
iny
lda (__8),y
lda (__14),y
sta SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y+1
// memcpy_to_vram((char)>VERA_SPRITE_ATTR, <VERA_SPRITE_ATTR+2, &SPRITE_ATTR+2, 4)
// memcpy_to_vram(vram_sprite_attr_bank, vram_sprite_pos, &SPRITE_ATTR+2, 4)
lda.z vram_sprite_pos
sta.z memcpy_to_vram.vdest
lda.z vram_sprite_pos+1
sta.z memcpy_to_vram.vdest+1
// Copy sprite positions to VRAM (the 4 relevant bytes in VERA_SPRITE_ATTR)
lda #<4
sta.z memcpy_to_vram.num
@ -179,22 +221,72 @@ irq_vsync: {
sta.z memcpy_to_vram.src
lda #>SPRITE_ATTR+2
sta.z memcpy_to_vram.src+1
ldx #VERA_SPRITE_ATTR>>$10
lda #<VERA_SPRITE_ATTR+2&$ffff
sta.z memcpy_to_vram.vdest
lda #>VERA_SPRITE_ATTR+2&$ffff
sta.z memcpy_to_vram.vdest+1
ldx #vram_sprite_attr_bank
jsr memcpy_to_vram
// *VERA_ISR = VERA_VSYNC
// Reset the VSYNC interrupt
lda #VERA_VSYNC
sta VERA_ISR
// asm
// Exit CX16 KERNAL IRQ
jmp $e034
// }
// vram_sprite_pos += sizeof(SPRITE_ATTR)
lda #SIZEOF_STRUCT_VERA_SPRITE
clc
adc.z vram_sprite_pos
sta.z vram_sprite_pos
bcc !+
inc.z vram_sprite_pos+1
!:
// i_x += 3
lda #3
clc
adc.z i_x
sta.z i_x
bcc !+
inc.z i_x+1
!:
// if(i_x>=241)
lda.z i_x+1
bne !+
lda.z i_x
cmp #$f1
bcc __b8
!:
// i_x -= 241
sec
lda.z i_x
sbc #$f1
sta.z i_x
lda.z i_x+1
sbc #0
sta.z i_x+1
__b8:
// i_y += 5
lda #5
clc
adc.z i_y
sta.z i_y
bcc !+
inc.z i_y+1
!:
// if(i_y>=251)
lda.z i_y+1
bne !+
lda.z i_y
cmp #$fb
bcc __b9
!:
// i_y -= 251
sec
lda.z i_y
sbc #$fb
sta.z i_y
lda.z i_y+1
sbc #0
sta.z i_y+1
__b9:
// for(char s=0;s<NUM_SPRITES;s++)
inc.z s
jmp __b5
}
main: {
// Copy 8* sprite attributes to VRAM
.label vram_sprite_attr = $a
.label s = 9
// memcpy_to_vram((char)>SPRITE_PIXELS_VRAM, <SPRITE_PIXELS_VRAM, SPRITE_PIXELS, sizeof(SPRITE_PIXELS))
// Copy sprite data to VRAM
lda #<$40*$40*SIZEOF_BYTE
@ -211,23 +303,24 @@ main: {
lda #>SPRITE_PIXELS_VRAM&$ffff
sta.z memcpy_to_vram.vdest+1
jsr memcpy_to_vram
// memcpy_to_vram((char)>VERA_SPRITE_ATTR, <VERA_SPRITE_ATTR, &SPRITE_ATTR, sizeof(SPRITE_ATTR))
// Copy sprite attributes to VRAM
lda #<SIZEOF_STRUCT_VERA_SPRITE
sta.z memcpy_to_vram.num
lda #>SIZEOF_STRUCT_VERA_SPRITE
sta.z memcpy_to_vram.num+1
lda #<SPRITE_ATTR
sta.z memcpy_to_vram.src
lda #>SPRITE_ATTR
sta.z memcpy_to_vram.src+1
ldx #VERA_SPRITE_ATTR>>$10
lda #<VERA_SPRITE_ATTR&$ffff
sta.z memcpy_to_vram.vdest
sta.z vram_sprite_attr
lda #>VERA_SPRITE_ATTR&$ffff
sta.z memcpy_to_vram.vdest+1
jsr memcpy_to_vram
sta.z vram_sprite_attr+1
lda #0
sta.z s
__b1:
// for(char s=0;s<NUM_SPRITES;s++)
lda.z s
cmp #$80
bcc __b2
// *VERA_CTRL &= ~VERA_DCSEL
// Makea border
//*VERA_CTRL |= VERA_DCSEL;
//*VERA_DC_HSTART = 16/4;
//*VERA_DC_HSTOP = 624/4;
//*VERA_DC_VSTART = 16/2;
//*VERA_DC_VSTOP = 464/2;
// Enable sprites
lda #VERA_DCSEL^$ff
and VERA_CTRL
@ -250,6 +343,49 @@ main: {
cli
// }
rts
__b2:
// SPRITE_ATTR.X += 10
lda #<$a
clc
adc SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X
sta SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X
lda #>$a
adc SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X+1
sta SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X+1
// SPRITE_ATTR.Y += 10
lda #<$a
clc
adc SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y
sta SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y
lda #>$a
adc SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y+1
sta SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y+1
// memcpy_to_vram((char)>VERA_SPRITE_ATTR, vram_sprite_attr, &SPRITE_ATTR, sizeof(SPRITE_ATTR))
lda.z vram_sprite_attr
sta.z memcpy_to_vram.vdest
lda.z vram_sprite_attr+1
sta.z memcpy_to_vram.vdest+1
lda #<SIZEOF_STRUCT_VERA_SPRITE
sta.z memcpy_to_vram.num
lda #>SIZEOF_STRUCT_VERA_SPRITE
sta.z memcpy_to_vram.num+1
lda #<SPRITE_ATTR
sta.z memcpy_to_vram.src
lda #>SPRITE_ATTR
sta.z memcpy_to_vram.src+1
ldx #VERA_SPRITE_ATTR>>$10
jsr memcpy_to_vram
// vram_sprite_attr += sizeof(SPRITE_ATTR)
lda #SIZEOF_STRUCT_VERA_SPRITE
clc
adc.z vram_sprite_attr
sta.z vram_sprite_attr
bcc !+
inc.z vram_sprite_attr+1
!:
// for(char s=0;s<NUM_SPRITES;s++)
inc.z s
jmp __b1
}
// Copy block of memory (from RAM to VRAM)
// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination in VRAM.
@ -257,13 +393,13 @@ main: {
// - vdest: The destination address in VRAM
// - src: The source address in RAM
// - num: The number of bytes to copy
// memcpy_to_vram(byte register(X) vbank, void* zp(2) vdest, void* zp(4) src, word zp(6) num)
// memcpy_to_vram(byte register(X) vbank, void* zp($c) vdest, void* zp($e) src, word zp($10) num)
memcpy_to_vram: {
.label end = 6
.label s = 4
.label vdest = 2
.label src = 4
.label num = 6
.label end = $10
.label s = $e
.label vdest = $c
.label src = $e
.label num = $10
// *VERA_CTRL &= ~VERA_ADDRSEL
// Select DATA0
lda #VERA_ADDRSEL^$ff

View File

@ -31,73 +31,116 @@ irq_vsync::@4: scope:[irq_vsync] from irq_vsync::@1
[11] sin_idx_y = $fb-1
to:irq_vsync::@2
irq_vsync::@2: scope:[irq_vsync] from irq_vsync::@1 irq_vsync::@4
[12] irq_vsync::$5 = sin_idx_x << 1
[13] irq_vsync::$7 = SINX + irq_vsync::$5
[14] *((word*)&SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X) = *irq_vsync::$7
[15] irq_vsync::$6 = sin_idx_y << 1
[16] irq_vsync::$8 = SINY + irq_vsync::$6
[17] *((word*)&SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y) = *irq_vsync::$8
[18] call memcpy_to_vram
[12] irq_vsync::i_x#0 = sin_idx_x
[13] irq_vsync::i_y#0 = sin_idx_y
to:irq_vsync::@5
irq_vsync::@5: scope:[irq_vsync] from irq_vsync::@2
[19] *VERA_ISR = VERA_VSYNC
irq_vsync::@5: scope:[irq_vsync] from irq_vsync::@2 irq_vsync::@9
[14] irq_vsync::vram_sprite_pos#2 = phi( irq_vsync::@2/(byte*)<VERA_SPRITE_ATTR+2, irq_vsync::@9/irq_vsync::vram_sprite_pos#1 )
[14] irq_vsync::i_y#3 = phi( irq_vsync::@2/irq_vsync::i_y#0, irq_vsync::@9/irq_vsync::i_y#9 )
[14] irq_vsync::i_x#3 = phi( irq_vsync::@2/irq_vsync::i_x#0, irq_vsync::@9/irq_vsync::i_x#7 )
[14] irq_vsync::s#2 = phi( irq_vsync::@2/0, irq_vsync::@9/irq_vsync::s#1 )
[15] if(irq_vsync::s#2<$80) goto irq_vsync::@6
to:irq_vsync::@7
irq_vsync::@7: scope:[irq_vsync] from irq_vsync::@5
[16] *VERA_ISR = VERA_VSYNC
asm { jmp$e034 }
to:irq_vsync::@return
irq_vsync::@return: scope:[irq_vsync] from irq_vsync::@5
[21] return
irq_vsync::@return: scope:[irq_vsync] from irq_vsync::@7
[18] return
to:@return
irq_vsync::@6: scope:[irq_vsync] from irq_vsync::@5
[19] irq_vsync::$11 = irq_vsync::i_x#3 << 1
[20] irq_vsync::$13 = SINX + irq_vsync::$11
[21] *((word*)&SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X) = *irq_vsync::$13
[22] irq_vsync::$12 = irq_vsync::i_y#3 << 1
[23] irq_vsync::$14 = SINY + irq_vsync::$12
[24] *((word*)&SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y) = *irq_vsync::$14
[25] memcpy_to_vram::vdest#2 = (void*)irq_vsync::vram_sprite_pos#2
[26] call memcpy_to_vram
to:irq_vsync::@12
irq_vsync::@12: scope:[irq_vsync] from irq_vsync::@6
[27] irq_vsync::vram_sprite_pos#1 = irq_vsync::vram_sprite_pos#2 + SIZEOF_STRUCT_VERA_SPRITE
[28] irq_vsync::i_x#1 = irq_vsync::i_x#3 + 3
[29] if(irq_vsync::i_x#1<$f1) goto irq_vsync::@8
to:irq_vsync::@10
irq_vsync::@10: scope:[irq_vsync] from irq_vsync::@12
[30] irq_vsync::i_x#2 = irq_vsync::i_x#1 - $f1
to:irq_vsync::@8
irq_vsync::@8: scope:[irq_vsync] from irq_vsync::@10 irq_vsync::@12
[31] irq_vsync::i_x#7 = phi( irq_vsync::@10/irq_vsync::i_x#2, irq_vsync::@12/irq_vsync::i_x#1 )
[32] irq_vsync::i_y#1 = irq_vsync::i_y#3 + 5
[33] if(irq_vsync::i_y#1<$fb) goto irq_vsync::@9
to:irq_vsync::@11
irq_vsync::@11: scope:[irq_vsync] from irq_vsync::@8
[34] irq_vsync::i_y#2 = irq_vsync::i_y#1 - $fb
to:irq_vsync::@9
irq_vsync::@9: scope:[irq_vsync] from irq_vsync::@11 irq_vsync::@8
[35] irq_vsync::i_y#9 = phi( irq_vsync::@11/irq_vsync::i_y#2, irq_vsync::@8/irq_vsync::i_y#1 )
[36] irq_vsync::s#1 = ++ irq_vsync::s#2
to:irq_vsync::@5
void main()
main: scope:[main] from __start::@1
[22] phi()
[23] call memcpy_to_vram
to:main::@2
main::@2: scope:[main] from main
[24] phi()
[25] call memcpy_to_vram
[37] phi()
[38] call memcpy_to_vram
to:main::@1
main::@1: scope:[main] from main main::@5
[39] main::vram_sprite_attr#2 = phi( main/(byte*)<VERA_SPRITE_ATTR, main::@5/main::vram_sprite_attr#1 )
[39] main::s#2 = phi( main/0, main::@5/main::s#1 )
[40] if(main::s#2<$80) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@2
[26] *VERA_CTRL = *VERA_CTRL & ~VERA_DCSEL
[27] *VERA_DC_VIDEO = *VERA_DC_VIDEO | VERA_SPRITES_ENABLE
main::@3: scope:[main] from main::@1
[41] *VERA_CTRL = *VERA_CTRL & ~VERA_DCSEL
[42] *VERA_DC_VIDEO = *VERA_DC_VIDEO | VERA_SPRITES_ENABLE
to:main::SEI1
main::SEI1: scope:[main] from main::@3
asm { sei }
to:main::@1
main::@1: scope:[main] from main::SEI1
[29] *KERNEL_IRQ = &irq_vsync
[30] *VERA_IEN = VERA_VSYNC
to:main::@4
main::@4: scope:[main] from main::SEI1
[44] *KERNEL_IRQ = &irq_vsync
[45] *VERA_IEN = VERA_VSYNC
to:main::CLI1
main::CLI1: scope:[main] from main::@1
main::CLI1: scope:[main] from main::@4
asm { cli }
to:main::@return
main::@return: scope:[main] from main::CLI1
[32] return
[47] return
to:@return
main::@2: scope:[main] from main::@1
[48] *((word*)&SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X) = *((word*)&SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_X) + $a
[49] *((word*)&SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y) = *((word*)&SPRITE_ATTR+OFFSET_STRUCT_VERA_SPRITE_Y) + $a
[50] memcpy_to_vram::vdest#1 = (void*)main::vram_sprite_attr#2
[51] call memcpy_to_vram
to:main::@5
main::@5: scope:[main] from main::@2
[52] main::vram_sprite_attr#1 = main::vram_sprite_attr#2 + SIZEOF_STRUCT_VERA_SPRITE
[53] main::s#1 = ++ main::s#2
to:main::@1
void memcpy_to_vram(byte memcpy_to_vram::vbank , void* memcpy_to_vram::vdest , void* memcpy_to_vram::src , word memcpy_to_vram::num)
memcpy_to_vram: scope:[memcpy_to_vram] from irq_vsync::@2 main main::@2
[33] memcpy_to_vram::num#3 = phi( irq_vsync::@2/4, main/(word)$40*$40*SIZEOF_BYTE, main::@2/SIZEOF_STRUCT_VERA_SPRITE )
[33] memcpy_to_vram::src#3 = phi( irq_vsync::@2/(void*)&SPRITE_ATTR+2, main/(void*)SPRITE_PIXELS, main::@2/(void*)&SPRITE_ATTR )
[33] memcpy_to_vram::vbank#3 = phi( irq_vsync::@2/(byte)>VERA_SPRITE_ATTR, main/0, main::@2/(byte)>VERA_SPRITE_ATTR )
[33] memcpy_to_vram::vdest#3 = phi( irq_vsync::@2/(void*)<VERA_SPRITE_ATTR+2, main/(void*)<SPRITE_PIXELS_VRAM, main::@2/(void*)<VERA_SPRITE_ATTR )
[34] *VERA_CTRL = *VERA_CTRL & ~VERA_ADDRSEL
[35] memcpy_to_vram::$0 = < memcpy_to_vram::vdest#3
[36] *VERA_ADDRX_L = memcpy_to_vram::$0
[37] memcpy_to_vram::$1 = > memcpy_to_vram::vdest#3
[38] *VERA_ADDRX_M = memcpy_to_vram::$1
[39] memcpy_to_vram::$2 = VERA_INC_1 | memcpy_to_vram::vbank#3
[40] *VERA_ADDRX_H = memcpy_to_vram::$2
[41] memcpy_to_vram::end#0 = (byte*)memcpy_to_vram::src#3 + memcpy_to_vram::num#3
[42] memcpy_to_vram::s#4 = (byte*)memcpy_to_vram::src#3
memcpy_to_vram: scope:[memcpy_to_vram] from irq_vsync::@6 main main::@2
[54] memcpy_to_vram::num#3 = phi( irq_vsync::@6/4, main/(word)$40*$40*SIZEOF_BYTE, main::@2/SIZEOF_STRUCT_VERA_SPRITE )
[54] memcpy_to_vram::src#3 = phi( irq_vsync::@6/(void*)&SPRITE_ATTR+2, main/(void*)SPRITE_PIXELS, main::@2/(void*)&SPRITE_ATTR )
[54] memcpy_to_vram::vbank#3 = phi( irq_vsync::@6/irq_vsync::vram_sprite_attr_bank, main/0, main::@2/(byte)>VERA_SPRITE_ATTR )
[54] memcpy_to_vram::vdest#3 = phi( irq_vsync::@6/memcpy_to_vram::vdest#2, main/(void*)<SPRITE_PIXELS_VRAM, main::@2/memcpy_to_vram::vdest#1 )
[55] *VERA_CTRL = *VERA_CTRL & ~VERA_ADDRSEL
[56] memcpy_to_vram::$0 = < memcpy_to_vram::vdest#3
[57] *VERA_ADDRX_L = memcpy_to_vram::$0
[58] memcpy_to_vram::$1 = > memcpy_to_vram::vdest#3
[59] *VERA_ADDRX_M = memcpy_to_vram::$1
[60] memcpy_to_vram::$2 = VERA_INC_1 | memcpy_to_vram::vbank#3
[61] *VERA_ADDRX_H = memcpy_to_vram::$2
[62] memcpy_to_vram::end#0 = (byte*)memcpy_to_vram::src#3 + memcpy_to_vram::num#3
[63] memcpy_to_vram::s#4 = (byte*)memcpy_to_vram::src#3
to:memcpy_to_vram::@1
memcpy_to_vram::@1: scope:[memcpy_to_vram] from memcpy_to_vram memcpy_to_vram::@2
[43] memcpy_to_vram::s#2 = phi( memcpy_to_vram/memcpy_to_vram::s#4, memcpy_to_vram::@2/memcpy_to_vram::s#1 )
[44] if(memcpy_to_vram::s#2!=memcpy_to_vram::end#0) goto memcpy_to_vram::@2
[64] memcpy_to_vram::s#2 = phi( memcpy_to_vram/memcpy_to_vram::s#4, memcpy_to_vram::@2/memcpy_to_vram::s#1 )
[65] if(memcpy_to_vram::s#2!=memcpy_to_vram::end#0) goto memcpy_to_vram::@2
to:memcpy_to_vram::@return
memcpy_to_vram::@return: scope:[memcpy_to_vram] from memcpy_to_vram::@1
[45] return
[66] return
to:@return
memcpy_to_vram::@2: scope:[memcpy_to_vram] from memcpy_to_vram::@1
[46] *VERA_DATA0 = *memcpy_to_vram::s#2
[47] memcpy_to_vram::s#1 = ++ memcpy_to_vram::s#2
[67] *VERA_DATA0 = *memcpy_to_vram::s#2
[68] memcpy_to_vram::s#1 = ++ memcpy_to_vram::s#2
to:memcpy_to_vram::@1

File diff suppressed because it is too large Load Diff

View File

@ -31,40 +31,73 @@ const nomodify dword VERA_SPRITE_ATTR = $1fc00
const nomodify byte VERA_VSYNC = 1
void __start()
void irq_vsync()
word~ irq_vsync::$5 zp[2]:12 4.0
word~ irq_vsync::$6 zp[2]:14 4.0
word*~ irq_vsync::$7 zp[2]:12 4.0
word*~ irq_vsync::$8 zp[2]:14 4.0
word~ irq_vsync::$11 zp[2]:22 22.0
word~ irq_vsync::$12 zp[2]:24 22.0
word*~ irq_vsync::$13 zp[2]:22 22.0
word*~ irq_vsync::$14 zp[2]:24 22.0
word irq_vsync::i_x
word irq_vsync::i_x#0 i_x zp[2]:3 2.0
word irq_vsync::i_x#1 i_x zp[2]:3 22.0
word irq_vsync::i_x#2 i_x zp[2]:3 22.0
word irq_vsync::i_x#3 i_x zp[2]:3 3.1818181818181817
word irq_vsync::i_x#7 i_x zp[2]:3 5.5
word irq_vsync::i_y
word irq_vsync::i_y#0 i_y zp[2]:5 4.0
word irq_vsync::i_y#1 i_y zp[2]:5 22.0
word irq_vsync::i_y#2 i_y zp[2]:5 22.0
word irq_vsync::i_y#3 i_y zp[2]:5 2.333333333333333
word irq_vsync::i_y#9 i_y zp[2]:5 16.5
byte irq_vsync::s
byte irq_vsync::s#1 s zp[1]:2 22.0
byte irq_vsync::s#2 s zp[1]:2 1.736842105263158
const nomodify byte irq_vsync::vram_sprite_attr_bank = (byte)>VERA_SPRITE_ATTR
byte* irq_vsync::vram_sprite_pos
byte* irq_vsync::vram_sprite_pos#1 vram_sprite_pos zp[2]:7 2.2
byte* irq_vsync::vram_sprite_pos#2 vram_sprite_pos zp[2]:7 2.2
void main()
byte main::s
byte main::s#1 s zp[1]:9 202.0
byte main::s#2 s zp[1]:9 43.285714285714285
byte* main::vram_sprite_attr
byte* main::vram_sprite_attr#1 vram_sprite_attr zp[2]:10 101.0
byte* main::vram_sprite_attr#2 vram_sprite_attr zp[2]:10 33.666666666666664
void memcpy_to_vram(byte memcpy_to_vram::vbank , void* memcpy_to_vram::vdest , void* memcpy_to_vram::src , word memcpy_to_vram::num)
byte~ memcpy_to_vram::$0 reg byte a 202.0
byte~ memcpy_to_vram::$1 reg byte a 202.0
byte~ memcpy_to_vram::$2 reg byte a 202.0
byte~ memcpy_to_vram::$0 reg byte a 2002.0
byte~ memcpy_to_vram::$1 reg byte a 2002.0
byte~ memcpy_to_vram::$2 reg byte a 2002.0
byte* memcpy_to_vram::end
byte* memcpy_to_vram::end#0 end zp[2]:6 183.66666666666669
byte* memcpy_to_vram::end#0 end zp[2]:16 16833.666666666664
word memcpy_to_vram::num
word memcpy_to_vram::num#3 num zp[2]:6 12.625
word memcpy_to_vram::num#3 num zp[2]:16 125.125
byte* memcpy_to_vram::s
byte* memcpy_to_vram::s#1 s zp[2]:4 2002.0
byte* memcpy_to_vram::s#2 s zp[2]:4 1368.3333333333335
byte* memcpy_to_vram::s#4 s zp[2]:4 202.0
byte* memcpy_to_vram::s#1 s zp[2]:14 200002.0
byte* memcpy_to_vram::s#2 s zp[2]:14 133668.3333333333
byte* memcpy_to_vram::s#4 s zp[2]:14 2002.0
void* memcpy_to_vram::src
void* memcpy_to_vram::src#3 src zp[2]:4
void* memcpy_to_vram::src#3 src zp[2]:14
byte memcpy_to_vram::vbank
byte memcpy_to_vram::vbank#3 reg byte x 16.833333333333332
byte memcpy_to_vram::vbank#3 reg byte x 166.83333333333334
void* memcpy_to_vram::vdest
void* memcpy_to_vram::vdest#3 vdest zp[2]:2 50.5
volatile word sin_idx_x loadstore zp[2]:8 1.9999999999999998
volatile word sin_idx_y loadstore zp[2]:10 1.3333333333333335
void* memcpy_to_vram::vdest#1 vdest zp[2]:12 202.0
void* memcpy_to_vram::vdest#2 vdest zp[2]:12 22.0
void* memcpy_to_vram::vdest#3 vdest zp[2]:12 528.5
volatile word sin_idx_x loadstore zp[2]:18 1.9999999999999998
volatile word sin_idx_y loadstore zp[2]:20 1.714285714285714
zp[2]:2 [ memcpy_to_vram::vdest#3 ]
zp[1]:2 [ irq_vsync::s#2 irq_vsync::s#1 ]
zp[2]:3 [ irq_vsync::i_x#3 irq_vsync::i_x#0 irq_vsync::i_x#7 irq_vsync::i_x#2 irq_vsync::i_x#1 ]
zp[2]:5 [ irq_vsync::i_y#3 irq_vsync::i_y#0 irq_vsync::i_y#9 irq_vsync::i_y#2 irq_vsync::i_y#1 ]
zp[2]:7 [ irq_vsync::vram_sprite_pos#2 irq_vsync::vram_sprite_pos#1 ]
zp[1]:9 [ main::s#2 main::s#1 ]
zp[2]:10 [ main::vram_sprite_attr#2 main::vram_sprite_attr#1 ]
zp[2]:12 [ memcpy_to_vram::vdest#3 memcpy_to_vram::vdest#2 memcpy_to_vram::vdest#1 ]
reg byte x [ memcpy_to_vram::vbank#3 ]
zp[2]:4 [ memcpy_to_vram::src#3 memcpy_to_vram::s#2 memcpy_to_vram::s#4 memcpy_to_vram::s#1 ]
zp[2]:6 [ memcpy_to_vram::num#3 memcpy_to_vram::end#0 ]
zp[2]:8 [ sin_idx_x ]
zp[2]:10 [ sin_idx_y ]
zp[2]:12 [ irq_vsync::$5 irq_vsync::$7 ]
zp[2]:14 [ irq_vsync::$6 irq_vsync::$8 ]
zp[2]:14 [ memcpy_to_vram::src#3 memcpy_to_vram::s#2 memcpy_to_vram::s#4 memcpy_to_vram::s#1 ]
zp[2]:16 [ memcpy_to_vram::num#3 memcpy_to_vram::end#0 ]
zp[2]:18 [ sin_idx_x ]
zp[2]:20 [ sin_idx_y ]
zp[2]:22 [ irq_vsync::$11 irq_vsync::$13 ]
zp[2]:24 [ irq_vsync::$12 irq_vsync::$14 ]
reg byte a [ memcpy_to_vram::$0 ]
reg byte a [ memcpy_to_vram::$1 ]
reg byte a [ memcpy_to_vram::$2 ]