From 98dc6f2e74fbfed3448f783111f3d479aad44b8f Mon Sep 17 00:00:00 2001 From: tilleul Date: Mon, 18 Jan 2021 07:03:03 +0100 Subject: [PATCH] updated from 8bitworkshop.com --- 8bitunity-plot_scroll.asm | 82 +++++++++++++++++++++++++++++ 8bitunity.asm | 108 ++++++++------------------------------ bin/8bitunity.asm.rom | Bin 94 -> 514 bytes hires.asm | 107 +++++++++++++++++++++++++++++++++++++ 4 files changed, 212 insertions(+), 85 deletions(-) create mode 100644 8bitunity-plot_scroll.asm create mode 100644 hires.asm diff --git a/8bitunity-plot_scroll.asm b/8bitunity-plot_scroll.asm new file mode 100644 index 0000000..bbdfc1a --- /dev/null +++ b/8bitunity-plot_scroll.asm @@ -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 \ No newline at end of file diff --git a/8bitunity.asm b/8bitunity.asm index 35deaba..de3395e 100644 --- a/8bitunity.asm +++ b/8bitunity.asm @@ -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" diff --git a/bin/8bitunity.asm.rom b/bin/8bitunity.asm.rom index bff8f3b8c717df03c26e50079d2b90034210e7ee..ed5c8bed60fd4569d27b778b7533ba9cf692b7bb 100644 GIT binary patch literal 514 zcmY$$;^+-H&>MKbhlgVk!;-fB!0*0Lo3KQR* zIP&R5=-BuK5l(Cf$7MXqY}2%>V@rP(UhQ S0}56^0jc}|D7XLxr1Al7yR@4C delta 33 pcmZo-iIehS=2*nA