mirror of
https://github.com/irmen/prog8.git
synced 2025-02-27 03:29:22 +00:00
cx16: added cx16.vaddr_autoincr() and cx16.vaddr_autodecr()
This commit is contained in:
parent
10d0ff252b
commit
4575a8fffe
@ -539,6 +539,8 @@ asmsub vpeek(ubyte bank @A, uword address @XY) -> ubyte @A {
|
||||
|
||||
asmsub vaddr(ubyte bank @A, uword address @R0, ubyte addrsel @R1, byte autoIncrOrDecrByOne @Y) clobbers(A) {
|
||||
; -- setup the VERA's data address register 0 or 1
|
||||
; with optional auto increment or decrement of 1.
|
||||
; Note that the vaddr_autoincr() and vaddr_autodecr() routines allow to set all possible strides, not just 1.
|
||||
%asm {{
|
||||
and #1
|
||||
pha
|
||||
@ -562,6 +564,84 @@ asmsub vaddr(ubyte bank @A, uword address @R0, ubyte addrsel @R1, byte autoIncrO
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub vaddr_autoincr(ubyte bank @A, uword address @R0, ubyte addrsel @R1, uword autoIncrAmount @R2) clobbers(A,Y) {
|
||||
; -- setup the VERA's data address register 0 or 1
|
||||
; including setting up optional auto increment amount.
|
||||
%asm {{
|
||||
jsr _setup
|
||||
lda cx16.r2H
|
||||
ora cx16.r2L
|
||||
beq +
|
||||
jsr _determine_incr_bits
|
||||
+ ora P8ZP_SCRATCH_REG
|
||||
sta cx16.VERA_ADDR_H
|
||||
rts
|
||||
|
||||
_setup and #1
|
||||
sta P8ZP_SCRATCH_REG
|
||||
lda cx16.r1
|
||||
and #1
|
||||
sta cx16.VERA_CTRL
|
||||
lda cx16.r0
|
||||
sta cx16.VERA_ADDR_L
|
||||
lda cx16.r0+1
|
||||
sta cx16.VERA_ADDR_M
|
||||
rts
|
||||
|
||||
_determine_incr_bits
|
||||
lda cx16.r2H
|
||||
bne _large
|
||||
lda cx16.r2L
|
||||
ldy #13
|
||||
- cmp _strides_lsb,y
|
||||
beq +
|
||||
dey
|
||||
bpl -
|
||||
+ tya
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
asl a
|
||||
rts
|
||||
_large ora cx16.r2L
|
||||
cmp #1 ; 256
|
||||
bne +
|
||||
lda #9<<4
|
||||
rts
|
||||
+ cmp #2 ; 512
|
||||
bne +
|
||||
lda #10<<4
|
||||
rts
|
||||
+ cmp #65 ; 320
|
||||
bne +
|
||||
lda #14<<4
|
||||
rts
|
||||
+ cmp #130 ; 640
|
||||
bne +
|
||||
lda #15<<4
|
||||
rts
|
||||
+ lda #0
|
||||
rts
|
||||
_strides_lsb .byte 0,1,2,4,8,16,32,64,128,255,255,40,80,160,255,255
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub vaddr_autodecr(ubyte bank @A, uword address @R0, ubyte addrsel @R1, uword autoDecrAmount @R2) clobbers(A,Y) {
|
||||
; -- setup the VERA's data address register 0 or 1
|
||||
; including setting up optional auto decrement amount.
|
||||
%asm {{
|
||||
jsr vaddr_autoincr._setup
|
||||
lda cx16.r2H
|
||||
ora cx16.r2L
|
||||
beq +
|
||||
jsr vaddr_autoincr._determine_incr_bits
|
||||
ora #%00001000 ; autodecrement
|
||||
+ ora P8ZP_SCRATCH_REG
|
||||
sta cx16.VERA_ADDR_H
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub vpoke(ubyte bank @A, uword address @R0, ubyte value @Y) clobbers(A) {
|
||||
; -- write a single byte to VERA's video memory
|
||||
; note: inefficient when writing multiple sequential bytes!
|
||||
|
@ -301,6 +301,10 @@ Strange assembler error
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
If the compilation of your program fails in the assembly step, please check that you have
|
||||
the required version of the 64tass assembler installed. See :ref:`requirements`.
|
||||
Also make sure that inside hand-written inlined assembly,
|
||||
you don't use symbols named just a single letter (especially 'a', 'x' and 'y').
|
||||
Sometimes these are interpreted as the CPU register of that name. To avoid such confusions,
|
||||
always use 2 or more letters for symbols in your assembly code.
|
||||
|
||||
|
||||
Community
|
||||
|
@ -1,26 +1,20 @@
|
||||
%import textio
|
||||
%zeropage basicsafe
|
||||
|
||||
main
|
||||
{
|
||||
sub start()
|
||||
{
|
||||
uword uw = 54321
|
||||
ubyte ub = 123
|
||||
word sw = -12345
|
||||
byte sb = -123
|
||||
cx16.set_screen_mode(128)
|
||||
|
||||
txt.print_uw(~ub as uword) ;132
|
||||
txt.nl()
|
||||
txt.print_ub(~uw as ubyte) ;206
|
||||
txt.nl()
|
||||
txt.print_uw(~sb as uword) ;122
|
||||
txt.nl()
|
||||
txt.print_ub(~sw as ubyte) ;56
|
||||
txt.nl()
|
||||
txt.print_w(-sb as word) ;123
|
||||
txt.nl()
|
||||
txt.print_b(-sw as byte) ;57
|
||||
txt.nl()
|
||||
cx16.vaddr_autoincr(0,320*100+100,1,2)
|
||||
repeat 16 {
|
||||
cx16.VERA_DATA1 = 0
|
||||
}
|
||||
cx16.vaddr_autodecr(0,320*110+100,1,1)
|
||||
repeat 16 {
|
||||
cx16.VERA_DATA1 = 0
|
||||
}
|
||||
|
||||
repeat {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user