Skip to content

Commit

Permalink
Issue #2352: gencon support for Aquarius+
Browse files Browse the repository at this point in the history
Compile with -pragma-define:CLIB_AQUARIUS_PLUS=1 to enable aq+ code
  • Loading branch information
suborb committed Jul 15, 2023
1 parent f6385d7 commit a3b7b2a
Show file tree
Hide file tree
Showing 25 changed files with 777 additions and 186 deletions.
8 changes: 7 additions & 1 deletion lib/target/aquarius/classic/aquarius_crt0.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@
defc crt0 = 1
INCLUDE "zcc_opt.def"


INCLUDE "target/aquarius/def/aqplus.def"

EXTERN _main ;main() is always external to crt0 code

PUBLIC cleanup ;jp'd to by exit()
PUBLIC l_dcal ;jp(hl)

PUBLIC CLIB_VIDEO_PAGE_PORT ;Video paging port for aq+

defc TAR__no_ansifont = 1
defc CONSOLE_ROWS = 24
defc CONSOLE_COLUMNS = 40
defc __CPU_CLOCK = 4000000

PUBLIC CLIB_AQUARIUS_PLUS
IFNDEF CLIB_AQUARIUS_PLUS
defc CLIB_AQUARIUS_PLUS = 0
ENDIF


IF startup = 1
Expand Down
3 changes: 3 additions & 0 deletions lib/target/aquarius/classic/ram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ IF !DEFINED_CRT_ORG_CODE
ENDIF


; Page video into 0xc000 -> 0xffff
defc CLIB_VIDEO_PAGE_PORT = PORT_BANK3

defc TAR__clib_exit_stack_size = 32
defc TAR__register_sp = -1
INCLUDE "crt/classic/crt_rules.inc"
Expand Down
4 changes: 3 additions & 1 deletion lib/target/aquarius/classic/rom.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
defc RAM_Start = 0x3900
INCLUDE "crt/classic/crt_rules.inc"

; Page video into 0x8000 - 0xc000
defc CLIB_VIDEO_PAGE_PORT = PORT_BANK2


org CRT_ORG_CODE

Expand Down Expand Up @@ -39,7 +42,6 @@ cleanup:
endloop:
jr endloop


defc __crt_org_bss = RAM_Start
; If we were given a model then use it
IF DEFINED_CRT_MODEL
Expand Down
21 changes: 21 additions & 0 deletions lib/target/aquarius/def/aqplus.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; Aquarius+ port definitions
;
; Ports are writable + readable




defc PORT_VCTRL = $e0

defc PORT_VPALSEL = $ea
defc PORT_VPALDATA = $eb

defc PORT_BANK0 = $f0
defc PORT_BANK1 = $f1
defc PORT_BANK2 = $f2
defc PORT_BANK3 = $f3





6 changes: 6 additions & 0 deletions lib/target/aquarius/def/aquarius.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@




defc DISPLAY = 12328
defc COLOUR_MAP = DISPLAY + 1024
24 changes: 20 additions & 4 deletions libsrc/target/aquarius/aquarius.lst
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
target/aquarius/stdio/bordercolour
target/aquarius/stdio/set_default_palette
target/aquarius/stdio/CRT_FONT
target/aquarius/stdio/cls_BITMAP
target/aquarius/stdio/cls_TEXT
target/aquarius/stdio/conio_map_colour
target/aquarius/stdio/conio_vars
target/aquarius/stdio/fgetc_cons
target/aquarius/stdio/getk
target/aquarius/stdio/fputc_cons
target/aquarius/stdio/generic_console
target/aquarius/stdio/conio_vars
target/aquarius/stdio/bordercolour
target/aquarius/stdio/conio_map_colour
target/aquarius/stdio/generic_console_attr
target/aquarius/stdio/generic_console_ioctl
target/aquarius/stdio/generic_console_vpeek
target/aquarius/stdio/get_video_base
target/aquarius/stdio/getk
target/aquarius/stdio/printc_BITMAP
target/aquarius/stdio/printc_TEXT
target/aquarius/stdio/scrollup_BITMAP
target/aquarius/stdio/scrollup_TEXT
target/aquarius/stdio/vpeek_BITMAP
target/aquarius/stdio/vpeek_TEXT
target/aquarius/stdio/xypos_BITMAP
target/aquarius/stdio/xypos_TEXT
@stdio/ansicore.lst
target/aquarius/stdio/ansi/f_ansi_attr
target/aquarius/stdio/ansi/f_ansi_bel
Expand Down
5 changes: 5 additions & 0 deletions libsrc/target/aquarius/stdio/CRT_FONT.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


PUBLIC CRT_FONT

defc CRT_FONT = 0
32 changes: 32 additions & 0 deletions libsrc/target/aquarius/stdio/cls_BITMAP.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

SECTION code_clib

PUBLIC cls_BITMAP

EXTERN __aquarius_video_pagein
EXTERN __aquarius_video_pageout

EXTERN __aquarius_video_base
EXTERN __aquarius_attr

cls_BITMAP:
call __aquarius_video_pagein
ld hl,(__aquarius_video_base)
ld de,hl
inc de
ld bc,+(40 * 25 * 8) - 1
ld (hl),0x00
ldir
ld hl,(__aquarius_video_base)
ld bc,$2000
add hl,bc
ld de,hl
inc de
ld bc,+(40 * 25) - 1
ld a,(__aquarius_attr)
ld (hl),a
ldir
call __aquarius_video_pageout
ret


24 changes: 24 additions & 0 deletions libsrc/target/aquarius/stdio/cls_TEXT.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

SECTION code_clib

PUBLIC cls_TEXT

INCLUDE "target/aquarius/def/aquarius.def"

EXTERN CONSOLE_COLUMNS
EXTERN CONSOLE_ROWS
EXTERN __aquarius_attr

cls_TEXT:
ld hl, DISPLAY
ld de, DISPLAY +1
ld bc, +(CONSOLE_COLUMNS * CONSOLE_ROWS) - 1
ld (hl),32
ldir
ld hl, COLOUR_MAP
ld de, COLOUR_MAP+1
ld bc, +(CONSOLE_COLUMNS * CONSOLE_ROWS) - 1
ld a,(__aquarius_attr)
ld (hl),a
ldir
ret
60 changes: 30 additions & 30 deletions libsrc/target/aquarius/stdio/conio_map_colour.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
; Used: hl,bc,f
;

MODULE code_clib
PUBLIC conio_map_colour
MODULE code_clib
PUBLIC conio_map_colour

EXTERN __CLIB_CONIO_NATIVE_COLOUR
EXTERN __CLIB_CONIO_NATIVE_COLOUR

conio_map_colour:
ld c,__CLIB_CONIO_NATIVE_COLOUR
rr c
ret c

and 15
ld c,a
ld b,0
ld hl,table_rgb
add hl,bc
ld a,(hl)
ret
ld c,__CLIB_CONIO_NATIVE_COLOUR
rr c
ret c

and 15
ld c,a
ld b,0
ld hl,table_rgb
add hl,bc
ld a,(hl)
ret

; 0 = black
; 1 = red
Expand All @@ -44,20 +44,20 @@ conio_map_colour:
; We'll go with the RGB table
SECTION rodata_clib
table_rgb:
defb $0 ;BLACK -> BLACK
defb $b ;BLUE -> DARK BLUE
defb $2 ;GREEN -> GREEN
defb $6 ;CYAN -> CYAN
defb $1 ;RED -> RED
defb $a ;MAGENTA -> MAGENTA
defb $e ;BROWN -> ORANGE
defb $8 ;LIGHTGRAY -> LIGHT GREY
defb $f ;DARKGRAY -> DARK GREY
defb $4 ;LIGHTBLUE -> BLUE
defb $d ;LIGHTGREEN -> LIGHT GREEN
defb $9 ;LIGHTCYAN -> BLUE GREEN
defb $c ;LIGHTRED -> LIGHT YELLOW
defb $5 ;LIGHTMAGENTA -> VIOLET
defb $3 ;YELLOW -> YELLOW
defb $7 ;WHITE -> WHITE
defb $0 ;BLACK -> BLACK
defb $b ;BLUE -> DARK BLUE
defb $2 ;GREEN -> GREEN
defb $6 ;CYAN -> CYAN
defb $1 ;RED -> RED
defb $a ;MAGENTA -> MAGENTA
defb $e ;BROWN -> ORANGE
defb $8 ;LIGHTGRAY -> LIGHT GREY
defb $f ;DARKGRAY -> DARK GREY
defb $4 ;LIGHTBLUE -> BLUE
defb $d ;LIGHTGREEN -> LIGHT GREEN
defb $9 ;LIGHTCYAN -> BLUE GREEN
defb $c ;LIGHTRED -> LIGHT YELLOW
defb $5 ;LIGHTMAGENTA -> VIOLET
defb $3 ;YELLOW -> YELLOW
defb $7 ;WHITE -> WHITE

27 changes: 22 additions & 5 deletions libsrc/target/aquarius/stdio/conio_vars.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@
; Shared variables between the VT100 and VT52 engines


MODULE conio_vars
SECTION data_clib
MODULE conio_vars
SECTION data_clib

PUBLIC __aquarius_attr
PUBLIC __aquarius_inverse
PUBLIC __aquarius_attr
PUBLIC __aquarius_inverse
PUBLIC __aquarius_mode
PUBLIC __aquarius_video_base

EXTERN CLIB_VIDEO_PAGE_PORT

.__aquarius_attr defb $70 ; White on Black
.__aquarius_inverse defb 7
.__aquarius_inverse defb 7
.__aquarius_mode defb 1 ; Text mode
.__aquarius_video_base defw 0 ; Base address respecting banking for AQ+ video


SECTION code_crt_init

; Set the base address for the video page
ld a,CLIB_VIDEO_PAGE_PORT
rrca
rrca
and @11000000
ld (__aquarius_video_base+1),a

0 comments on commit a3b7b2a

Please sign in to comment.