From 558290100cc3722207269b3e1103eebcb70f837e Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Thu, 5 Apr 2018 11:20:43 -0700 Subject: [PATCH] Clear MSB for DLB/DAB --- src/libsrc/jitcore.pla | 37 +++++++++++++++++++++++-------------- src/samplesrc/rogue.map.pla | 4 ++-- src/vmsrc/apple/plvm01.s | 4 ++++ src/vmsrc/apple/plvm02.s | 35 +++++++++++++++++++++++++++++++++++ src/vmsrc/apple/plvm03.s | 4 ++++ src/vmsrc/apple/plvm802.s | 4 ++++ src/vmsrc/apple/plvmjit02.s | 35 +++++++++++++++++++++++++++++++++++ 7 files changed, 107 insertions(+), 16 deletions(-) diff --git a/src/libsrc/jitcore.pla b/src/libsrc/jitcore.pla index dad5198..43b7d50 100644 --- a/src/libsrc/jitcore.pla +++ b/src/libsrc/jitcore.pla @@ -312,21 +312,16 @@ def compiler(defptr)#0 codeptr = codeptr + 2 fin VX-- // DEX - if VY == j - ^codeptr = $98; codeptr++ // TYA -> LDA #imm - else - *codeptr = $A9+(j<<8) // LDA #imm - codeptr = codeptr + 2 - fin - codeptr->0 = $18 // CLC - codeptr=>1 = $E065 // ADC IFPL - codeptr=>3 = $D095+(VX<<8) // STA ESTKL,X + codeptr=>0 = $A9+(j<<8) // LDA #imm + codeptr->2 = $18 // CLC + codeptr=>3 = $E065 // ADC IFPL + codeptr=>5 = $D095+(VX<<8) // STA ESTKL,X if VY == 0 - codeptr->5 = $98 // TYA -> LDA #00 - codeptr = codeptr + 6 + codeptr->7 = $98 // TYA -> LDA #00 + codeptr = codeptr + 8 else - codeptr=>5 = $00A9 // LDA #$00 - codeptr = codeptr + 7 + codeptr=>7 = $00A9 // LDA #$00 + codeptr = codeptr + 9 fin codeptr=>0 = $E165 // ADC IFPH codeptr=>2 = $C095+(VX<<8) // STA ESTKH,X @@ -857,7 +852,14 @@ def compiler(defptr)#0 fin *codeptr = $E091 // STA (IFP),Y codeptr = codeptr + 2 - break + if VY <> 0 + *codeptr = $00A0 // LDY #$00 + codeptr = codeptr + 2 + VY = 0 + fin + *codeptr = $C094+(VX<<8) // STY ESTKH,X + codeptr = codeptr + 2 + break is $6E // DLW i++ j = ^(bytecode+i) @@ -973,6 +975,13 @@ def compiler(defptr)#0 if opcode == $7C //puts("DAB $"); puth(*(bytecode+i)) codeptr = codeptr + 3 + if VY <> 0 + *codeptr = $00A0 // LDY #$00 + codeptr = codeptr + 2 + VY = 0 + fin + *codeptr = $C094+(VX<<8) // STY ESTKH,X + codeptr = codeptr + 2 else codeptr=>3 = $C0B4+(VX<<8) // LDY ESTKH,X codeptr->5 = $8C // STY abs+1 diff --git a/src/samplesrc/rogue.map.pla b/src/samplesrc/rogue.map.pla index 3190296..0ddf1a9 100644 --- a/src/samplesrc/rogue.map.pla +++ b/src/samplesrc/rogue.map.pla @@ -260,8 +260,8 @@ end // export def drawmap(xorg, yorg, viewfield, viewdir, lightdist, viewdist) - byte o, l, dist, tile, adjtile, occluded, darkness - word ymap, xmap, imap + byte l, dist, tile, adjtile, occluded, darkness + word ymap, xmap, imap, o byte yscr, xscr if viewdist > beamdepth diff --git a/src/vmsrc/apple/plvm01.s b/src/vmsrc/apple/plvm01.s index 4e73678..e9e14d3 100644 --- a/src/vmsrc/apple/plvm01.s +++ b/src/vmsrc/apple/plvm01.s @@ -658,6 +658,8 @@ DLB INY ;+INC_IP TAY LDA ESTKL,X STA (IFP),Y + LDA #$00 + STA ESTKH,X LDY IPY JMP NEXTOP DLW INY ;+INC_IP @@ -718,6 +720,8 @@ DAB INY ;+INC_IP STA ESTKH-1,X LDA ESTKL,X STA (ESTKH-2,X) + LDA #$00 + STA ESTKH,X JMP NEXTOP DAW INY ;+INC_IP LDA (IP),Y diff --git a/src/vmsrc/apple/plvm02.s b/src/vmsrc/apple/plvm02.s index 758ff06..abb60cb 100755 --- a/src/vmsrc/apple/plvm02.s +++ b/src/vmsrc/apple/plvm02.s @@ -1448,6 +1448,8 @@ DLB INY ;+INC_IP TAY LDA ESTKL,X STA (IFP),Y + LDA #$00 + STA ESTKH,X LDY IPY JMP NEXTOP DLW INY ;+INC_IP @@ -1509,6 +1511,8 @@ DAB INY ;+INC_IP STA ESTKH-1,X LDA ESTKL,X STA (ESTKH-2,X) + LDA #$00 + STA ESTKH,X JMP NEXTOP DAW INY ;+INC_IP LDA (IP),Y @@ -2262,6 +2266,37 @@ CDAW INY ;+INC_IP LDY IPY JMP NEXTOP CDAWEND +; + LDA #DAB + LDY #(CDABEND-CDAB) + JSR OPCPY +CDAB INY ;+INC_IP + LDA (IP),Y + STA ESTKH-2,X + INY ;+INC_IP + LDA (IP),Y + STA ESTKH-1,X + LDA ESTKL,X + STA (ESTKH-2,X) + STZ ESTKH,X + JMP NEXTOP +CDABEND +; + LDA #DLB + LDY #(CDLBEND-CDLB) + JSR OPCPY +CDLB INY ;+INC_IP + LDA (IP),Y + STY IPY + TAY + LDA ESTKL,X + STA (IFP),Y + STZ ESTKH,X + LDY IPY + JMP NEXTOP +CDLBEND ; LDA #ISFLS diff --git a/src/vmsrc/apple/plvm03.s b/src/vmsrc/apple/plvm03.s index 3059570..a62f8a0 100755 --- a/src/vmsrc/apple/plvm03.s +++ b/src/vmsrc/apple/plvm03.s @@ -984,6 +984,8 @@ DLB INY ;+INC_IP TAY LDA ESTKL,X STA (IFP),Y + LDA #$00 + STA ESTKH,X LDY IPY JMP NEXTOP DLW INY ;+INC_IP @@ -1044,6 +1046,8 @@ DAB INY ;+INC_IP STA ESTKH-1,X LDA ESTKL,X STA (ESTKH-2,X) + LDA #$00 + STA ESTKH,X JMP NEXTOP DAW INY ;+INC_IP LDA (IP),Y diff --git a/src/vmsrc/apple/plvm802.s b/src/vmsrc/apple/plvm802.s index 9f8b860..3dc02a5 100644 --- a/src/vmsrc/apple/plvm802.s +++ b/src/vmsrc/apple/plvm802.s @@ -1262,6 +1262,8 @@ DLB INY ;+INC_IP LDA TOS,S STA (IFP),Y +ACCMEM16 ; 16 BIT A/M + AND #$00FF + STA TOS,S TXY JMP NEXTOP DLW INY ;+INC_IP @@ -1304,6 +1306,8 @@ DAB INY ;+INC_IP LDA TOS,S STA (TMP) +ACCMEM16 ; 16 BIT A/M + AND #$00FF + STA TOS,S INY ;+INC_IP JMP NEXTOP DAW INY ;+INC_IP diff --git a/src/vmsrc/apple/plvmjit02.s b/src/vmsrc/apple/plvmjit02.s index 979ef67..7a0bac2 100755 --- a/src/vmsrc/apple/plvmjit02.s +++ b/src/vmsrc/apple/plvmjit02.s @@ -1511,6 +1511,8 @@ DLB INY ;+INC_IP TAY LDA ESTKL,X STA (IFP),Y + LDA #$00 + STA ESTKH,X LDY IPY JMP NEXTOP DLW INY ;+INC_IP @@ -1572,6 +1574,8 @@ DAB INY ;+INC_IP STA ESTKH-1,X LDA ESTKL,X STA (ESTKH-2,X) + LDA #$00 + STA ESTKH,X JMP NEXTOP DAW INY ;+INC_IP LDA (IP),Y @@ -2304,6 +2308,37 @@ CDAW INY ;+INC_IP LDY IPY JMP NEXTOP CDAWEND +; + LDA #DAB + LDY #(CDABEND-CDAB) + JSR OPCPY +CDAB INY ;+INC_IP + LDA (IP),Y + STA ESTKH-2,X + INY ;+INC_IP + LDA (IP),Y + STA ESTKH-1,X + LDA ESTKL,X + STA (ESTKH-2,X) + STZ ESTKH,X + JMP NEXTOP +CDABEND +; + LDA #DLB + LDY #(CDLBEND-CDLB) + JSR OPCPY +CDLB INY ;+INC_IP + LDA (IP),Y + STY IPY + TAY + LDA ESTKL,X + STA (IFP),Y + STZ ESTKH,X + LDY IPY + JMP NEXTOP +CDLBEND ; LDA #ISFLS