Skip to content

Commit

Permalink
Merge pull request #2393 from zx70/master
Browse files Browse the repository at this point in the history
lambda: optional ROM variants
  • Loading branch information
zx70 committed Sep 21, 2023
2 parents 6078623 + 4f4e219 commit 63fdf37
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 37 deletions.
5 changes: 5 additions & 0 deletions lib/config/lambda.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#
# Target configuration file for Lambda 8300 (AKA Power 3000..)
# 'cac3' subtype is for CAC-3 and NF300 clones, 'mono' subtypes are for the earlier ROM version not supporting color commands
#

# Lambda has custom library requirements
Expand All @@ -20,5 +21,9 @@ CLIB default -llambda_clib -lndos -lgfxlambda -LDESTDIR/lib/clibs/ixiy
SUBTYPE none
SUBTYPE default -startup=102 -Cz+zx81 -Cz--lambda
SUBTYPE fast -startup=101 -Cz+zx81 -Cz--lambda
SUBTYPE mono -startup=202 -Cz+zx81 -Cz--lambda
SUBTYPE monofast -startup=201 -Cz+zx81 -Cz--lambda
SUBTYPE cac3 -startup=302 -Cz+zx81 -Cz--lambda
SUBTYPE cac3fast -startup=301 -Cz+zx81 -Cz--lambda

INCLUDE alias.inc
28 changes: 27 additions & 1 deletion lib/target/lambda/classic/lambda_altint.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
;
; - - - - - - -
;
; $Id: lambda_altint.def,v 1.1 2015-08-04 06:48:23 stefano Exp $
; $Id: lambda_altint.def $
;
; - - - - - - -

Expand All @@ -30,7 +30,15 @@ PUBLIC zx_slow
;----------------------------------------------------------------
zx_fast:
call restore81
IF (startup=102)
jp $D5E ; FAST !
ENDIF
IF (startup=202)
jp $36C ; FAST ! (Monochrome ROM)
ENDIF
IF (startup=302)
jp $E06 ; FAST ! (CAC-3 and NF300)
ENDIF

;--------------------------------------------------------------
;========
Expand All @@ -40,7 +48,17 @@ zx_fast:
zx_slow:
altint_on:
call restore81

IF (startup=102)
call $12A5 ; SLOW
ENDIF
IF (startup=202)
call $281 ; SLOW (Monochrome ROM)
ENDIF
IF (startup=302)
call $13BE ; SLOW (CAC-3 and NF300)
ENDIF

ld hl,L0281
HRG_Sync:
push hl
Expand All @@ -60,7 +78,15 @@ nosync:

altint_off:
call altint_on ; restore registers and make sure we are in SLOW mode
IF (startup=102)
ld hl,$1323 ; on the ZX81 this was $0281
ENDIF
IF (startup=202)
ld hl,$300 ; Lambda monochrome ROM
ENDIF
IF (startup=302)
ld hl,$143C ; CAC-3 and NF300
ENDIF
jr HRG_Sync


Expand Down
80 changes: 70 additions & 10 deletions lib/target/lambda/classic/lambda_altint_core.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
; Note: a swap between IX and IY happens "on the fly" during assembly !
; ----------------------------------------------------------------------------------------
;
; $Id: lambda_altint_core.def,v 1.2 2016-07-14 13:30:10 pauloscustodio Exp $
; $Id: lambda_altint_core.def $
;
; - - - - - - -

; MEMOTECH HRG won't work on the Lambda, it requires a specific D-FILE vector,
; but the LAMBDA drivers points directly to the video memory.
; PUBLIC MTCH_P1
; PUBLIC MTCH_P2
; PUBLIC MTCH_P3

; I'm restoring this entry point to allow a 50hz hack, setting (MTCH_P3+1)=16 should do the trick
PUBLIC MTCH_P3

PUBLIC L0292
; G007 HRG won't work on the Lambda
Expand All @@ -25,6 +27,10 @@ PUBLIC L0292
;; DISPLAY-1
L0229:
LD HL,($4034) ; fetch two-byte system variable FRAMES.

IF (startup=202)
DEC HL
ENDIF
LD A,H
AND $7F
OR L
Expand All @@ -37,8 +43,19 @@ L0229:
; ---

;; ANOTHER
L0237: SCF ; Set Carry Flag
LD C,0
L0237:
SCF ; Set Carry Flag

; The following instruction was probably just to bias the video sync
; removing it seems to make EightyOne happier,
; hope I'm not compromising the picture on a real TV (60hz)

;IF (startup=202)
; LD B,(HL)
;ELSE
; LD C,0
;ENDIF


;; OVER-NC
L0239: LD H,A ;
Expand All @@ -56,10 +73,19 @@ L0239: LD H,A ;

;; DISPLAY-2
L023E:
IF (startup=102)
CALL $D74 ; routine KEYBOARD
ENDIF
IF (startup=202)
CALL $33D ; routine KEYBOARD (monochrome)
ENDIF
IF (startup=302)
CALL $E1C ; routine KEYBOARD (CAC-3, NF300)
ENDIF

LD BC,($4025) ; sv LAST_K
LD ($4025),HL ; sv LAST_K
LD D,B
LD D,B ; The monochrome ROM uses E to save B.. D is fine, anyway.
ADD A,$02 ;
ADD B
SBC HL,BC ;
Expand Down Expand Up @@ -110,10 +136,22 @@ L026A: DJNZ L026A ; to LOOP-B
L0281:
; MTCH_P2:
; G007_P2: ; the ROW couter patch for the G007 should be adjusted because..
LD BC,$0119 ; ..on the ZX81 C and B are inverted
IF (startup=202)
LD BC,$1901 ; Monochrome ROM
ELSE
LD BC,$0119 ; ..on the ZX81 and on monochrome ROM C and B are inverted
ENDIF
LD A,(0) ; on ZX81.. LD A,R
LD A,$F5 ;
IF (startup=102)
CALL $1666 ; routine DISPLAY-5 ($02B5 on the ZX81)
ENDIF
IF (startup=202)
CALL $337 ; routine DISPLAY-5 on monochrome ROM
ENDIF
IF (startup=302)
CALL $182F ; routine DISPLAY-5 on CAC-3 and NF300
ENDIF
NOP
NOP
DEC HL ;
Expand All @@ -122,7 +160,6 @@ L0281:

; ---


;; R-IX-2
L028F: JP L0229 ; to DISPLAY-1

Expand All @@ -134,21 +171,44 @@ L0292: POP IY ; return address to IX register (-IXIY swap).
; Modified here to keep IY unchanged

ld a,($4028) ; load B with MARGIN
; MTCH_P3:
MTCH_P3:
add 0 ; more blank lines for fast application code and correct sync
ld b,a

IF (startup=202)
ld c,a
ELSE
ld b,a
ENDIF
ld a,($403B) ; test CDFLAG
and 128 ; is in FAST mode ?
IF (startup=102)
jp z,$204 ; if so, jp to DISPLAY-4 ($02a9 on the ZX81)
ENDIF
IF (startup=202)
jp z,$32B ; if so, jp to DISPLAY-4 (monochrome ROM entry)
ENDIF
IF (startup=302)
jp z,$25F ; if so, jp to DISPLAY-4 (CAC-3 and NF300)
ENDIF

; jp $29e ; this could save 6 bytes, but I'm not sure if the display timing will be correct..
; better to reach the 'out' instruction first
IF (startup=202)
ld a,c
ELSE
ld a,b
ENDIF
dec a
neg
ex af,af
out ($FE),a

IF (startup=102)
jp $1FF ; POP registers and RET

ENDIF
IF (startup=202)
jp $326 ; POP registers and RET
ENDIF
IF (startup=302)
jp $25A ; POP registers and RET (CAC-3 and NF300)
ENDIF
71 changes: 64 additions & 7 deletions lib/target/zx81/classic/zx81_crt0.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
; Values for "startup" from 3 to 6 activate the WRX HRG modes
; Values between 13 and 17 activate the ARX HRG modes
; LAMBDA 8300/POWER 3000 modes: startup=101 and startup=102
; LAMBDA 8300 monochrome ROM: startup=201 and startup=202
; LAMBDA 8300 CAC-3 and NF300 ROM: startup=301 and startup=302
;
; OPTIMIZATIONS:
;
Expand All @@ -25,7 +27,7 @@
;
; - - - - - - -
;
; $Id: zx81_crt0.asm,v 1.59 2016-07-15 21:03:25 dom Exp $
; $Id: zx81_crt0.asm $
;
; - - - - - - -

Expand Down Expand Up @@ -160,16 +162,25 @@ IF (!DEFINED_startup | (startup=1))
;out ($fd),a ; nmi off
ENDIF


; LAMBDA 8300
IF (startup>100)
IF (startup=101)
; FAST mode, safest way to use the special registers
call $D5E
ENDIF
IF (startup=102)
IF (startup=201)
; FAST mode in monochrome ROM
call $36C
ENDIF
IF (startup=301)
; FAST mode on CAC-3 and NF300
call $E06
ENDIF
IF ((startup=102) | (startup=202) | (startup=302))
call altint_on
ENDIF
ELSE

IF (startup>=2)
IF ((startup=3)|(startup=5)|(startup=13)|(startup=15)|(startup=23)|(startup=25))
ld a,1
Expand Down Expand Up @@ -248,11 +259,17 @@ cleanup:
call restore81

IF (startup>100)
IF (startup=101)
; LAMBDA specific exit resume code (if any)
IF (startup=101)
call $12A5 ; SLOW
ENDIF
IF (startup=102)
IF (startup=201)
call $281 ; SLOW (Monochrome ROM)
ENDIF
IF (startup=301)
call $13BE ; SLOW (CAC-3 amd NF300)
ENDIF
IF ((startup=102) | (startup=202) | (startup=302))
call altint_off
ENDIF
ELSE
Expand Down Expand Up @@ -317,8 +334,7 @@ ENDIF

IF (startup>100)
; LAMBDA modes
IF (startup=102)
IF ((startup=102) | (startup=202) | (startup=302))
INCLUDE "target/lambda/classic/lambda_altint.asm"
ENDIF
ELSE
Expand Down Expand Up @@ -372,6 +388,47 @@ _zx_slow:
ret
ENDIF

IF (startup>100)

; LAMBDA JP tables
PUBLIC __lambda_keyboard
PUBLIC __lambda_decode
PUBLIC __lambda_cls

; Color Lambda ROM
IF ((startup=101) | (startup=102))
__lambda_keyboard:
jp $D74
__lambda_decode:
jp $1877
__lambda_cls:
jp $1C7D
ENDIF

; Monochrome Lambda ROM (earlier?)
IF ((startup=201) | (startup=202))
__lambda_keyboard:
jp $33D
__lambda_decode:
jp $95E
__lambda_cls:
jp $BD0
ENDIF

; CAC-3 and NF300
IF ((startup=301) | (startup=302))
__lambda_keyboard:
jp $E1C
__lambda_decode:
jp $1A40
__lambda_cls:
jp $1602
ENDIF

ENDIF


;-----------
; Now some variables
;-----------
Expand Down
10 changes: 6 additions & 4 deletions libsrc/target/zx81/stdio/fgetc_cons.asm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; Stefano Bodrato - Apr. 2000
;
;
; $Id: fgetc_cons.asm,v 1.8 2016-06-12 17:32:01 dom Exp $
; $Id: fgetc_cons.asm $
;

SECTION code_clib
Expand All @@ -21,7 +21,8 @@
call restore81
.fgcloop
IF FORlambda
call 3444
EXTERN __lambda_keyboard
call __lambda_keyboard
ELSE
call 699
ENDIF
Expand All @@ -30,7 +31,7 @@ ENDIF
jr nc,fgcloop
.wloop
IF FORlambda
call 3444
call __lambda_keyboard
ELSE
call 699
ENDIF
Expand All @@ -40,7 +41,8 @@ ENDIF
ld b,h
ld c,l
IF FORlambda
call 6263
EXTERN __lambda_decode
call __lambda_decode
ELSE
call 1981
ENDIF
Expand Down
Loading

0 comments on commit 63fdf37

Please sign in to comment.