Browse Source

Workaround Z280 CPU Bug for LZSA2

The LZSA2 decompressor invoked a known Z280 CPU bug.  A small modification to the code resolves this.
pull/351/head v3.3.0-dev.12
Wayne Warthen 3 years ago
parent
commit
c628ba10f2
  1. 2
      Source/HBIOS/cfg_rcz280.asm
  2. 20
      Source/HBIOS/unlzsa2s.asm
  3. 2
      Source/ver.inc
  4. 2
      Source/ver.lib

2
Source/HBIOS/cfg_rcz280.asm

@ -20,7 +20,7 @@ CPUFAM .EQU CPU_Z280 ; CPU FAMILY: CPU_[Z80|Z180|Z280]
BIOS .EQU BIOS_WBW ; HARDWARE BIOS: BIOS_[WBW|UNA] BIOS .EQU BIOS_WBW ; HARDWARE BIOS: BIOS_[WBW|UNA]
BATCOND .EQU FALSE ; ENABLE LOW BATTERY WARNING MESSAGE BATCOND .EQU FALSE ; ENABLE LOW BATTERY WARNING MESSAGE
HBIOS_MUTEX .EQU FALSE ; ENABLE REENTRANT CALLS TO HBIOS (ADDS OVERHEAD) HBIOS_MUTEX .EQU FALSE ; ENABLE REENTRANT CALLS TO HBIOS (ADDS OVERHEAD)
USELZSA2 .EQU FALSE ; ENABLE FONT COMPRESSION
USELZSA2 .EQU TRUE ; ENABLE FONT COMPRESSION
TICKFREQ .EQU 50 ; DESIRED PERIODIC TIMER INTERRUPT FREQUENCY (HZ) TICKFREQ .EQU 50 ; DESIRED PERIODIC TIMER INTERRUPT FREQUENCY (HZ)
; ;
BOOT_TIMEOUT .EQU -1 ; AUTO BOOT TIMEOUT IN SECONDS, -1 TO DISABLE, 0 FOR IMMEDIATE BOOT_TIMEOUT .EQU -1 ; AUTO BOOT TIMEOUT IN SECONDS, -1 TO DISABLE, 0 FOR IMMEDIATE

20
Source/HBIOS/unlzsa2s.asm

@ -60,8 +60,8 @@
; 3. This notice may not be removed or altered from any source distribution. ; 3. This notice may not be removed or altered from any source distribution.
; ;
; #DEFINE BACKWARD_DECOMPRESS ; uncomment for data compressed with option -b (+5 bytes, -3% speed)
; #DEFINE AVOID_SELFMODIFYING_CODE ; uncomment to disallow self-modifying code (-1 byte, -4% speed)
; #DEFINE BACKWARD_DECOMPRESS ; uncomment for data compressed with option -b (+5 bytes, -3% speed)
; #DEFINE AVOID_SELFMODIFYING_CODE ; uncomment to disallow self-modifying code (-1 byte, -4% speed)
#IFNDEF BACKWARD_DECOMPRESS #IFNDEF BACKWARD_DECOMPRESS
@ -79,7 +79,7 @@
#DEFINE ADD_OFFSET \ #DEFINE ADD_OFFSET \
#DEFCONT \ ld a,e \ sub l \ ld l,a #DEFCONT \ ld a,e \ sub l \ ld l,a
#DEFCONT \ ld a,d \ sbc h \ ld h,a ; 6*4 = 24t / 6 bytes
#DEFCONT \ ld a,d \ sbc h \ ld h,a ; 6*4 = 24t / 6 bytes
#DEFINE BLOCKCOPY \ #DEFINE BLOCKCOPY \
#DEFCONT \ lddr #DEFCONT \ lddr
@ -118,7 +118,7 @@ MatchLen: and %00000111 \ add a,2 \ cp 9
call z,ExtendedCode call z,ExtendedCode
CopyMatch: ld c,a CopyMatch: ld c,a
push hl ; BC = len, DE = dest, HL = -offset, SP -> [src]
push hl ; BC = len, DE = dest, HL = -offset, SP -> [src]
#IFNDEF AVOID_SELFMODIFYING_CODE #IFNDEF AVOID_SELFMODIFYING_CODE
PrevOffset .EQU $+1 \ ld hl,0 PrevOffset .EQU $+1 \ ld hl,0
@ -126,8 +126,8 @@ PrevOffset .EQU $+1 \ ld hl,0
push ix \ pop hl push ix \ pop hl
#ENDIF #ENDIF
ADD_OFFSET ADD_OFFSET
BLOCKCOPY ; BC = 0, DE = dest
pop hl ; HL = src
BLOCKCOPY ; BC = 0, DE = dest
pop hl ; HL = src
ReadToken: ld a,(hl) \ NEXT_HL \ push af ReadToken: ld a,(hl) \ NEXT_HL \ push af
and %00011000 \ jr z,NoLiterals and %00011000 \ jr z,NoLiterals
@ -163,12 +163,16 @@ ExtendedCode: call ReadNibble \ inc a \ jr z,ExtraByte
ExtraByte ld a,15 \ add a,c \ add a,(hl) \ NEXT_HL \ ret nc ExtraByte ld a,15 \ add a,c \ add a,(hl) \ NEXT_HL \ ret nc
ld a,(hl) \ NEXT_HL ld a,(hl) \ NEXT_HL
ld b,(hl) \ NEXT_HL \ ret nz ld b,(hl) \ NEXT_HL \ ret nz
pop bc ; RET is not needed, because RET from ReadNibble is sufficient
pop bc ; RET is not needed, because RET from ReadNibble is sufficient
ReadNibble: ld c,a ReadNibble: ld c,a
skipLDCA xor a \ ex af,af' \ ret m
skipLDCA xor a \ nop \ ex af,af' \ ret m ; NOP for Z280 bug
ld a,(hl) \ or $F0 \ ex af,af' ld a,(hl) \ or $F0 \ ex af,af'
ld a,(hl) \ NEXT_HL \ or $0F ld a,(hl) \ NEXT_HL \ or $0F
rrca \ rrca \ rrca \ rrca \ ret rrca \ rrca \ rrca \ rrca \ ret
; The extraneous NOP instruction above is to workaround a bug in the
; Z280 processor where ex af,af' can copy rather than swap the flags
; register.
; See https://www.retrobrewcomputers.org/forum/index.php?t=msg&goto=10183&

2
Source/ver.inc

@ -2,7 +2,7 @@
#DEFINE RMN 3 #DEFINE RMN 3
#DEFINE RUP 0 #DEFINE RUP 0
#DEFINE RTP 0 #DEFINE RTP 0
#DEFINE BIOSVER "3.3.0-dev.11"
#DEFINE BIOSVER "3.3.0-dev.12"
#define rmj RMJ #define rmj RMJ
#define rmn RMN #define rmn RMN
#define rup RUP #define rup RUP

2
Source/ver.lib

@ -3,5 +3,5 @@ rmn equ 3
rup equ 0 rup equ 0
rtp equ 0 rtp equ 0
biosver macro biosver macro
db "3.3.0-dev.11"
db "3.3.0-dev.12"
endm endm

Loading…
Cancel
Save