mirror of
https://github.com/irmen/prog8.git
synced 2024-10-16 18:23:59 +00:00
sprites example
This commit is contained in:
parent
500777bf78
commit
aeb963673a
@ -173,7 +173,7 @@ functioncall_stmt :
|
|||||||
|
|
||||||
|
|
||||||
expression_list :
|
expression_list :
|
||||||
expression (',' EOL? expression)*
|
expression (',' EOL? expression)* // you can split the expression list over several lines
|
||||||
;
|
;
|
||||||
|
|
||||||
returnstmt : 'return' expression_list? ;
|
returnstmt : 'return' expression_list? ;
|
||||||
@ -198,7 +198,7 @@ wordsuffix : '.w' ;
|
|||||||
|
|
||||||
booleanliteral : 'true' | 'false' ;
|
booleanliteral : 'true' | 'false' ;
|
||||||
|
|
||||||
arrayliteral : '[' EOL? expression (',' EOL? expression)* EOL? ']' ;
|
arrayliteral : '[' EOL? expression (',' EOL? expression)* EOL? ']' ; // you can split the array list over several lines
|
||||||
|
|
||||||
stringliteral : STRING ;
|
stringliteral : STRING ;
|
||||||
|
|
||||||
|
@ -3,19 +3,99 @@
|
|||||||
|
|
||||||
~ main {
|
~ main {
|
||||||
|
|
||||||
|
ubyte[63] balloonsprite = [ %00000000, %01111111, %00000000,
|
||||||
|
%00000001, %11111111, %11000000,
|
||||||
|
%00000011, %11111111, %11100000,
|
||||||
|
%00000011, %11100011, %11100000,
|
||||||
|
%00000111, %11011100, %11110000,
|
||||||
|
%00000111, %11011101, %11110000,
|
||||||
|
%00000111, %11011100, %11110000,
|
||||||
|
%00000011, %11100011, %11100000,
|
||||||
|
%00000011, %11111111, %11100000,
|
||||||
|
%00000011, %11111111, %11100000,
|
||||||
|
%00000010, %11111111, %10100000,
|
||||||
|
%00000001, %01111111, %01000000,
|
||||||
|
%00000001, %00111110, %01000000,
|
||||||
|
%00000000, %10011100, %10000000,
|
||||||
|
%00000000, %10011100, %10000000,
|
||||||
|
%00000000, %01001001, %00000000,
|
||||||
|
%00000000, %01001001, %00000000,
|
||||||
|
%00000000, %00111110, %00000000,
|
||||||
|
%00000000, %00111110, %00000000,
|
||||||
|
%00000000, %00111110, %00000000,
|
||||||
|
%00000000, %00011100, %00000000 ]
|
||||||
|
|
||||||
|
const uword sprite_data_address = 13*64 ; // safe area inside the tape buffer
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
c64.STROUT("balloon sprites!\n")
|
c64.STROUT("balloon sprites!\n")
|
||||||
|
c64.STROUT("...we are all floating...\n")
|
||||||
|
|
||||||
const uword SP0X = $d000 ; @todo "address-of" operator '&' so we can write &c64.SP0X
|
; copy the ballon sprite data to the correct address and setup the sprite pointers
|
||||||
const uword SP0Y = $d001 ; @todo "address-of" operator '&' so we can write &c64.SP0Y
|
; @todo make a memcopy function for this, that calls c64utils.memcopy
|
||||||
|
for ubyte i in 0 to 62 {
|
||||||
for ubyte i in 0 to 7 {
|
;@(sprite_data_address+i) = @(balloonsprite+i) ; @todo nice error message
|
||||||
@(SP0X+i*2) = 30+i*30
|
@(sprite_data_address+i) = balloonsprite[i]
|
||||||
@(SP0Y+i*2) = 100+i*10
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c64.SPRPTR0 = sprite_data_address//64
|
||||||
|
c64.SPRPTR1 = sprite_data_address//64
|
||||||
|
c64.SPRPTR2 = sprite_data_address//64
|
||||||
|
c64.SPRPTR3 = sprite_data_address//64
|
||||||
|
c64.SPRPTR4 = sprite_data_address//64
|
||||||
|
c64.SPRPTR5 = sprite_data_address//64
|
||||||
|
c64.SPRPTR6 = sprite_data_address//64
|
||||||
|
c64.SPRPTR7 = sprite_data_address//64
|
||||||
|
|
||||||
|
c64.SP0X = 30+30*0
|
||||||
|
c64.SP1X = 30+30*1
|
||||||
|
c64.SP2X = 30+30*2
|
||||||
|
c64.SP3X = 30+30*3
|
||||||
|
c64.SP4X = 30+30*4
|
||||||
|
c64.SP5X = 30+30*5
|
||||||
|
c64.SP6X = 30+30*6
|
||||||
|
c64.SP7X = 30+30*7
|
||||||
|
|
||||||
|
c64.SP0Y = 100+10*0
|
||||||
|
c64.SP1Y = 100+10*1
|
||||||
|
c64.SP2Y = 100+10*2
|
||||||
|
c64.SP3Y = 100+10*3
|
||||||
|
c64.SP4Y = 100+10*4
|
||||||
|
c64.SP5Y = 100+10*5
|
||||||
|
c64.SP6Y = 100+10*6
|
||||||
|
c64.SP7Y = 100+10*7
|
||||||
|
|
||||||
c64.SPENA = 255 ; enable all sprites
|
c64.SPENA = 255 ; enable all sprites
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
~ irq {
|
||||||
|
|
||||||
|
sub irq() {
|
||||||
|
c64.SP0Y--
|
||||||
|
c64.SP1Y--
|
||||||
|
c64.SP2Y--
|
||||||
|
c64.SP3Y--
|
||||||
|
c64.SP4Y--
|
||||||
|
c64.SP5Y--
|
||||||
|
c64.SP6Y--
|
||||||
|
c64.SP7Y--
|
||||||
|
|
||||||
|
|
||||||
|
; const uword SP0X = $d000
|
||||||
|
; for ubyte i in 0 to 7 {
|
||||||
|
; @(SP0X+i*2) = @(SP0X+i*2) + 1 ; @todo this doesn't read (or write?) the correct values..
|
||||||
|
; ubyte r = rnd()
|
||||||
|
; if r>228
|
||||||
|
; ; @(SP0X+i*2)++ ; @todo allow this
|
||||||
|
; @(SP0X+i*2) = @(SP0X+i*2)+1
|
||||||
|
; else {
|
||||||
|
; if r<28
|
||||||
|
; @(SP0X+i*2) = @(SP0X+i*2)-1
|
||||||
|
; }
|
||||||
|
; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,11 @@
|
|||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
|
|
||||||
uword vic = $d000
|
ubyte[63] balloonsprite = [ 0,127,0,1,255,192,3,255,224,3,231,224,
|
||||||
const uword cvic = $d000
|
7,217,240,7,223,240,7,217,240,3,231,224,
|
||||||
|
3,255,224,3,255,224,2,255,160,1,127,64,
|
||||||
@(cvic+$20) = 7
|
1,62,64,0,156,128,0,156,128,0,73,0,0,73,0,
|
||||||
@(cvic+$21) = @(cvic+$20)
|
0,62,0,0,62,0,0,62,0,0,28,0 ]
|
||||||
|
|
||||||
@(vic+$20) = 5
|
|
||||||
@(vic+$21) = @(vic+$20)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,6 +208,7 @@ Array types are also supported. They can be made of bytes, words and floats::
|
|||||||
This means byte arrays should be <= 256 elements, word arrays <= 128 elements, and float
|
This means byte arrays should be <= 256 elements, word arrays <= 128 elements, and float
|
||||||
arrays <= 51 elements. This limit may or may not be lifted in a future version.
|
arrays <= 51 elements. This limit may or may not be lifted in a future version.
|
||||||
|
|
||||||
|
You can split an array initializer list over several lines if you want.
|
||||||
|
|
||||||
Note that the various keywords for the data type and variable type (``byte``, ``word``, ``const``, etc.)
|
Note that the various keywords for the data type and variable type (``byte``, ``word``, ``const``, etc.)
|
||||||
can't be used as *identifiers* elsewhere. You can't make a variable, block or subroutine with the name ``byte``
|
can't be used as *identifiers* elsewhere. You can't make a variable, block or subroutine with the name ``byte``
|
||||||
|
@ -254,6 +254,7 @@ type identifier type storage size example var declara
|
|||||||
(screencodes) implicit first byte = length, no 0-byte
|
(screencodes) implicit first byte = length, no 0-byte
|
||||||
=============== ======================= ================= =========================================
|
=============== ======================= ================= =========================================
|
||||||
|
|
||||||
|
**arrays:** you can split an array initializer list over several lines if you want.
|
||||||
|
|
||||||
**hexadecimal numbers:** you can use a dollar prefix to write hexadecimal numbers: ``$20ac``
|
**hexadecimal numbers:** you can use a dollar prefix to write hexadecimal numbers: ``$20ac``
|
||||||
|
|
||||||
|
@ -317,11 +317,11 @@ memcopy16_up .proc
|
|||||||
; clobbers A, X, Y
|
; clobbers A, X, Y
|
||||||
|
|
||||||
memcopy .proc
|
memcopy .proc
|
||||||
sta SCRATCH_ZPWORD2
|
sta c64.SCRATCH_ZPWORD2
|
||||||
sty SCRATCH_ZPWORD2+1
|
sty c64.SCRATCH_ZPWORD2+1
|
||||||
ldy #0
|
ldy #0
|
||||||
- lda (SCRATCH_ZPWORD1), y
|
- lda (c64.SCRATCH_ZPWORD1), y
|
||||||
sta (SCRATCH_ZPWORD2), y
|
sta (c64.SCRATCH_ZPWORD2), y
|
||||||
iny
|
iny
|
||||||
dex
|
dex
|
||||||
bne -
|
bne -
|
||||||
|
Loading…
Reference in New Issue
Block a user