mirror of
https://github.com/irmen/prog8.git
synced 2026-04-22 08:16:49 +00:00
add sys.set_rasterline on c64 and c128 targets as well (cx16 already had it)
This commit is contained in:
@@ -567,9 +567,18 @@ asmsub set_rasterirq(uword handler @AY, uword rasterpos @R0) clobbers(A) {
|
||||
sei
|
||||
sta user_vector
|
||||
sty user_vector+1
|
||||
|
||||
lda #%01111111
|
||||
sta c64.CIA1ICR ; "switch off" interrupts signals from cia-1
|
||||
sta c64.CIA2ICR ; "switch off" interrupts signals from cia-2
|
||||
lda c64.CIA1ICR ; ack previous irq
|
||||
lda c64.CIA2ICR ; ack previous irq
|
||||
lda cx16.r0
|
||||
ldy cx16.r0+1
|
||||
jsr _setup_raster_irq
|
||||
jsr sys.set_rasterline
|
||||
lda #%00000001
|
||||
sta c64.IREQMASK ; enable raster interrupt signals from vic
|
||||
|
||||
lda #<_raster_irq_handler
|
||||
sta cbm.CINV
|
||||
lda #>_raster_irq_handler
|
||||
@@ -601,26 +610,7 @@ _run_custom
|
||||
user_vector .word ?
|
||||
.send BSS
|
||||
|
||||
|
||||
_setup_raster_irq
|
||||
pha
|
||||
lda #%01111111
|
||||
sta c64.CIA1ICR ; "switch off" interrupts signals from cia-1
|
||||
sta c64.CIA2ICR ; "switch off" interrupts signals from cia-2
|
||||
and c64.SCROLY
|
||||
sta c64.SCROLY ; clear most significant bit of raster position
|
||||
lda c64.CIA1ICR ; ack previous irq
|
||||
lda c64.CIA2ICR ; ack previous irq
|
||||
pla
|
||||
sta c64.RASTER ; set the raster line number where interrupt should occur
|
||||
cpy #0
|
||||
beq +
|
||||
lda c64.SCROLY
|
||||
ora #%10000000
|
||||
sta c64.SCROLY ; set most significant bit of raster position
|
||||
+ lda #%00000001
|
||||
sta c64.IREQMASK ; enable raster interrupt signals from vic
|
||||
rts
|
||||
; !notreached!
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -634,13 +624,27 @@ _setup_raster_irq
|
||||
sta sys.set_rasterirq.user_vector
|
||||
sty sys.set_rasterirq.user_vector+1
|
||||
lda cx16.r0L
|
||||
sta c64.RASTER
|
||||
; TODO set high bit
|
||||
ldy cx16.r0H
|
||||
jsr sys.set_rasterline
|
||||
plp
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub set_rasterline(uword line @AY) {
|
||||
; -- only set a new raster line for the raster IRQ
|
||||
%asm {{
|
||||
sta c64.RASTER ; set the raster line number where interrupt should occur
|
||||
lda c64.SCROLY
|
||||
and #%01111111
|
||||
cpy #0
|
||||
beq +
|
||||
ora #%10000000
|
||||
+ sta c64.SCROLY ; clear most significant bit of raster position
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub reset_system() {
|
||||
; Soft-reset the system back to initial power-on Basic prompt.
|
||||
%asm {{
|
||||
|
||||
@@ -574,9 +574,18 @@ asmsub set_rasterirq(uword handler @AY, uword rasterpos @R0) clobbers(A) {
|
||||
sei
|
||||
sta user_vector
|
||||
sty user_vector+1
|
||||
|
||||
lda #%01111111
|
||||
sta c64.CIA1ICR ; "switch off" interrupts signals from cia-1
|
||||
sta c64.CIA2ICR ; "switch off" interrupts signals from cia-2
|
||||
lda c64.CIA1ICR ; ack previous irq
|
||||
lda c64.CIA2ICR ; ack previous irq
|
||||
lda cx16.r0
|
||||
ldy cx16.r0+1
|
||||
jsr _setup_raster_irq
|
||||
jsr sys.set_rasterline
|
||||
lda #%00000001
|
||||
sta c64.IREQMASK ; enable raster interrupt signals from vic
|
||||
|
||||
lda #<_raster_irq_handler
|
||||
sta cbm.CINV
|
||||
lda #>_raster_irq_handler
|
||||
@@ -609,25 +618,7 @@ _run_custom
|
||||
user_vector .word ?
|
||||
.send BSS
|
||||
|
||||
_setup_raster_irq
|
||||
pha
|
||||
lda #%01111111
|
||||
sta c64.CIA1ICR ; "switch off" interrupts signals from cia-1
|
||||
sta c64.CIA2ICR ; "switch off" interrupts signals from cia-2
|
||||
and c64.SCROLY
|
||||
sta c64.SCROLY ; clear most significant bit of raster position
|
||||
lda c64.CIA1ICR ; ack previous irq
|
||||
lda c64.CIA2ICR ; ack previous irq
|
||||
pla
|
||||
sta c64.RASTER ; set the raster line number where interrupt should occur
|
||||
cpy #0
|
||||
beq +
|
||||
lda c64.SCROLY
|
||||
ora #%10000000
|
||||
sta c64.SCROLY ; set most significant bit of raster position
|
||||
+ lda #%00000001
|
||||
sta c64.IREQMASK ; enable raster interrupt signals from vic
|
||||
rts
|
||||
; !notreached!
|
||||
}}
|
||||
}
|
||||
|
||||
@@ -641,13 +632,27 @@ _setup_raster_irq
|
||||
sta sys.set_rasterirq.user_vector
|
||||
sty sys.set_rasterirq.user_vector+1
|
||||
lda cx16.r0L
|
||||
sta c64.RASTER
|
||||
; TODO set high bit
|
||||
ldy cx16.r0H
|
||||
jsr sys.set_rasterline
|
||||
plp
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub set_rasterline(uword line @AY) {
|
||||
; -- only set a new raster line for the raster IRQ
|
||||
%asm {{
|
||||
sta c64.RASTER ; set the raster line number where interrupt should occur
|
||||
lda c64.SCROLY
|
||||
and #%01111111
|
||||
cpy #0
|
||||
beq +
|
||||
ora #%10000000
|
||||
+ sta c64.SCROLY ; clear most significant bit of raster position
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
|
||||
asmsub reset_system() {
|
||||
; Soft-reset the system back to initial power-on Basic prompt.
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
; Simple routines to control sprites.
|
||||
|
||||
; They're not written for high performance, but for simplicity.
|
||||
; That's why they control 1 sprite at a time. \
|
||||
; That's why they control 1 sprite at a time.
|
||||
; The exceptions are pos_batch() and pos_batch_split(); these are quite efficient
|
||||
; to update sprite positions of multiple sprites in one call.
|
||||
|
||||
; HIGH PERFORMANCE sprite handling would probably have a copy of the sprite registers for each sprite instead,
|
||||
; and a unrolled loop that copies those into the VERA registers when needed.
|
||||
|
||||
; note: sprites z-order will be in front of all layers.
|
||||
; note: collision mask is not supported here yet.
|
||||
; note: "palette offset" is counted as 0-15 (vera multiplies the offset by 16 to get at the actual color index)
|
||||
|
||||
@@ -197,6 +197,7 @@ These routines are::
|
||||
sys.set_irq(uword handler_address)
|
||||
sys.set_rasterirq(uword handler_address, uword rasterline)
|
||||
sys.update_rasterirq(uword handler_address, uword rasterline)
|
||||
sys.set_rasterline(uword rasterline)
|
||||
sys.restore_irq() ; set everything back to the systems default irq handler
|
||||
|
||||
The IRQ handler routine must return a boolean value (0 or 1) in the A register:
|
||||
|
||||
@@ -112,7 +112,7 @@ Future Things and Ideas
|
||||
|
||||
IR/VM
|
||||
-----
|
||||
- is it possible to use LOADFIELD/STOREFIELD instructions more?
|
||||
- is it possible to use LOADFIELD/STOREFIELD instructions even more?
|
||||
- make multiple classes of registers and maybe also categorize by life time , to prepare for better register allocation in the future
|
||||
SYSCALL_ARGS, // Reserved for syscall arguments (r99000-99099, r99100-99199)
|
||||
FUNCTION_PARAMS, // For passing function parameters
|
||||
@@ -161,7 +161,6 @@ IR/VM
|
||||
Libraries
|
||||
---------
|
||||
- Add split-word array sorting routines to sorting module?
|
||||
- See if the raster interrupt handler on the C64 can be tweaked to be a more stable raster irq
|
||||
- pet32 target: make syslib more complete (missing kernal routines)?
|
||||
- need help with: PET disk routines (OPEN, SETLFS etc are not exposed as kernal calls)
|
||||
- c128 target: make syslib more complete (missing kernal routines)?
|
||||
@@ -172,7 +171,7 @@ Optimizations
|
||||
|
||||
- check that expressions such as targetvar = value1 + value2 , targetvar = value1 ^ value2 etc. use the target variable directly and not use needless temp var / registers
|
||||
- Port benchmarks from https://thred.github.io/c-bench-64/ to prog8 and see how it stacks up.
|
||||
- Since fixing the missing zp-var initialization, programs grew in size again because STZ's reappered. Can we add more intelligent (and correct!) optimizations to remove those STZs that might be redundant again?
|
||||
- Since fixing the missing zp-var initialization, programs grew in size again because STZ's reappeared. Can we add more intelligent (and correct!) optimizations to remove those STZs that might be redundant again?
|
||||
- in Identifier: use typedarray of strings instead of listOf? Other places?
|
||||
- Compilation speed: try to join multiple modifications in 1 result in the AST processors instead of returning it straight away every time
|
||||
- Compare output of some Oscar64 samples to what prog8 does for the equivalent code (see https://github.com/drmortalwombat/OscarTutorials/tree/main and https://github.com/drmortalwombat/oscar64/tree/main/samples)
|
||||
|
||||
@@ -56,7 +56,7 @@ irq {
|
||||
sprites.set_sprites_Y(sprites_Y)
|
||||
}
|
||||
|
||||
sys.update_rasterirq(&irq.multiplexer, sprites_Y+1)
|
||||
sys.set_rasterline(sprites_Y+1)
|
||||
c64.EXTCOL--
|
||||
return system_irq
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user