updated from 8bitworkshop.com

This commit is contained in:
tilleul 2021-01-18 07:03:03 +01:00
parent c02e7d8965
commit 98dc6f2e74
4 changed files with 212 additions and 85 deletions

82
8bitunity-plot_scroll.asm Normal file
View File

@ -0,0 +1,82 @@
hiresXZP = $ec
hiresYZP = $ed
hiresAddrZP = $fc
inputAddrZP = $fa
outputAddrZP = $ee
scr2outRowsZP = $ce
inp2scrRowsZP = $eb
bytesPerRowZP = $e3
toggleMainAuxZP = $42
blitSHR subroutine
ldx #0
loopRow:
; Copy Screen Address from Hires Tables (using Line Offset Y and Byte Offset X)
ldy hiresYZP ; Y-Offset to Hires Line
lda hiresLinesHI,y
sta loopCopy1+2 ; LDA $HIlo,Y -- SMC -- +2 cycle
sta loopCopy2+5 ; STA $HIlo,Y -- SMC -- +5 cycles
lda hiresLinesLO,y
adc hiresXZP ; X-Offset to Hires Byte
sta loopCopy1+1 ; LDA $hiLO,Y -- SMC -- +2 cycle
sta loopCopy2+8 ; STA $hiLO,Y -- SMC -- +5 cycles
; Copy bytes from SHR buffer to ouput
screen2output:
lda outputAddrZP+1
beq input2screen ; If high-byte is zero, then skip
ldy #0 ; Y loop: Copy xxx bytes per row
loopCopy1: ; Copy 1 byte
lda $2000,y ; SMC: -1 cycle /byteperrow / line
sta (outputAddrZP),y
iny
cpy bytesPerRowZP
bne loopCopy1 ; Iterate Y loop
; Copy bytes from input to SHR buffer
cpx inp2scrRowsZP ; Check number of input rows (for cropped sprites)
bcs incAddress1
input2screen:
clc
lda inputAddrZP+1
beq incAddress1 ; If high-byte is zero, then skip
ldy #0 ; Y loop: Copy xxx bytes per row
loopCopy2:
lda (inputAddrZP),y ; Copy 1 byte
sta $2000,y ; SMC: -1 cycle / byteperrow / line
iny
cpy bytesPerRowZP ; Iterate Y loop
bne loopCopy2
incAddress1:
clc ; Increment address of output block
lda outputAddrZP
adc bytesPerRowZP ; Move by xxx bytes
sta outputAddrZP
bcc nocarry1 ; Check if carry to high-byte
inc outputAddrZP+1
nocarry1:
incAddress2:
clc ; Increment address of input block
lda inputAddrZP
adc bytesPerRowZP ; Move by xxx bytes
sta inputAddrZP
bcc nocarry2 ; Check if carry to high byte
inc inputAddrZP+1
nocarry2:
nextRow:
; Move to next row
inc hiresYZP ; Increment Hires Line offset
inx
cpx scr2outRowsZP
bcc loopRow ; Iterate X loop (rows)
rts

View File

@ -1,92 +1,30 @@
processor 6502
seg.u ZEROPAGE ; uninitialized zero-page variables
org $0
kbd = $c000
kbstrb = $c010
speaker = $c030
_hiresLinesHI = $00
_hiresLinesLO = $01
hiresXZP = $ec
hiresYZP = $ed
hiresAddrZP = $fc
inputAddrZP = $fa
outputAddrZP = $ee
scr2outRowsZP = $ce
inp2scrRowsZP = $eb
bytesPerRowZP = $e3
toggleMainAuxZP = $42
seg CODE
org $803 ; starting address
Start
jmp Start ; endless loop
graphx = $c050
text = $c051
page1 = $c054
hires = $c057
org $803
ldx #0
loopRow:
; Copy Screen Address from Hires Tables (using Line Offset Y and Byte Offset X)
ldy hiresYZP ; Y-Offset to Hires Line
lda _hiresLinesHI,y
sta loopCopy1+2 ; LDA $HIlo,Y -- SMC -- +2 cycle
sta loopCopy2+5 ; STA $HIlo,Y -- SMC -- +5 cycles
lda _hiresLinesLO,y
adc hiresXZP ; X-Offset to Hires Byte
sta loopCopy1+1 ; LDA $hiLO,Y -- SMC -- +2 cycle
sta loopCopy2+8 ; STA $hiLO,Y -- SMC -- +5 cycles
; Copy bytes from SHR buffer to ouput
screen2output:
lda outputAddrZP+1
beq input2screen ; If high-byte is zero, then skip
ldy #0 ; Y loop: Copy xxx bytes per row
loopCopy1: ; Copy 1 byte
lda $2000,y ; SMC: -1 cycle /byteperrow / line
sta (outputAddrZP),y
iny
cpy bytesPerRowZP
bne loopCopy1 ; Iterate Y loop
; Copy bytes from input to SHR buffer
cpx inp2scrRowsZP ; Check number of input rows (for cropped sprites)
bcs incAddress1
input2screen:
clc
lda inputAddrZP+1
beq incAddress1 ; If high-byte is zero, then skip
ldy #0 ; Y loop: Copy xxx bytes per row
loopCopy2:
lda (inputAddrZP),y ; Copy 1 byte
sta $2000,y ; SMC: -1 cycle / byteperrow / line
iny
cpy bytesPerRowZP ; Iterate Y loop
bne loopCopy2
incAddress1:
clc ; Increment address of output block
lda outputAddrZP
adc bytesPerRowZP ; Move by xxx bytes
sta outputAddrZP
bcc nocarry1 ; Check if carry to high-byte
inc outputAddrZP+1
nocarry1:
incAddress2:
clc ; Increment address of input block
lda inputAddrZP
adc bytesPerRowZP ; Move by xxx bytes
sta inputAddrZP
bcc nocarry2 ; Check if carry to high byte
inc inputAddrZP+1
nocarry2:
nextRow:
; Move to next row
inc hiresYZP ; Increment Hires Line offset
inx
cpx scr2outRowsZP
bcc loopRow ; Iterate X loop (rows)
rts
jsr clear_hgr1
sta graphx
sta text
Start jmp Start
include "8bitunity-plot_scroll.asm"
include "hires.asm"

Binary file not shown.

107
hires.asm Normal file
View File

@ -0,0 +1,107 @@
;draw_bmp subroutine
; ldy ypos
; lda height
; sta ycounter
;.nextline lda ytableh,y
; sta draw_bmp_eor+2
; sta .draw_sta+2
; lda ytablel,y
; sta draw_bmp_eor+1
; sta .draw_sta+1
; lda width
; sta xcounter
; ldx xpos
;draw_byteaddr lda $1000
; cpx #$28
; bcs .incxl
; cpy #$bf
; bcs .incxl
;draw_bmp_eor sta $2000,x
;.draw_sta sta $2000,x
;.incxl inc draw_byteaddr+1
; bne .cont
; inc draw_byteaddr+2
;.cont inx
; dec xcounter
; bne draw_byteaddr
; iny
; dec ycounter
; bne .nextline
; stx xpos
; rts
clear_hgr1 subroutine
lda #$20
sta .base_addr+2
ldy #$1F
lda #$00
sta .base_addr+1
.loop ldx #$00
.base_addr sta $2000,x
inx
bne .base_addr
inc .base_addr+2
dey
bpl .loop
rts
hiresLinesHI
hex 2024282C3034383C
hex 2024282C3034383C
hex 2125292D3135393D
hex 2125292D3135393D
hex 22262A2E32363A3E
hex 22262A2E32363A3E
hex 23272B2F33373B3F
hex 23272B2F33373B3F
hex 2024282C3034383C
hex 2024282C3034383C
hex 2125292D3135393D
hex 2125292D3135393D
hex 22262A2E32363A3E
hex 22262A2E32363A3E
hex 23272B2F33373B3F
hex 23272B2F33373B3F
hex 2024282C3034383C
hex 2024282C3034383C
hex 2125292D3135393D
hex 2125292D3135393D
hex 22262A2E32363A3E
hex 22262A2E32363A3E
hex 23272B2F33373B3F
hex 23272B2F33373B3F
hiresLinesLO
hex 0000000000000000
hex 8080808080808080
hex 0000000000000000
hex 8080808080808080
hex 0000000000000000
hex 8080808080808080
hex 0000000000000000
hex 8080808080808080
hex 2828282828282828
hex A8A8A8A8A8A8A8A8
hex 2828282828282828
hex A8A8A8A8A8A8A8A8
hex 2828282828282828
hex A8A8A8A8A8A8A8A8
hex 2828282828282828
hex A8A8A8A8A8A8A8A8
hex 5050505050505050
hex D0D0D0D0D0D0D0D0
hex 5050505050505050
hex D0D0D0D0D0D0D0D0
hex 5050505050505050
hex D0D0D0D0D0D0D0D0
hex 5050505050505050
hex D0D0D0D0D0D0D0D0