From a3b7b2a0f4a6399c4462d0e4948244ae0b5ad5f6 Mon Sep 17 00:00:00 2001 From: dom Date: Sat, 15 Jul 2023 22:31:54 +0100 Subject: [PATCH] Issue #2352: gencon support for Aquarius+ Compile with -pragma-define:CLIB_AQUARIUS_PLUS=1 to enable aq+ code --- lib/target/aquarius/classic/aquarius_crt0.asm | 8 +- lib/target/aquarius/classic/ram.asm | 3 + lib/target/aquarius/classic/rom.asm | 4 +- lib/target/aquarius/def/aqplus.def | 21 ++ lib/target/aquarius/def/aquarius.def | 6 + libsrc/target/aquarius/aquarius.lst | 24 ++- libsrc/target/aquarius/stdio/CRT_FONT.asm | 5 + libsrc/target/aquarius/stdio/cls_BITMAP.asm | 32 +++ libsrc/target/aquarius/stdio/cls_TEXT.asm | 24 +++ .../aquarius/stdio/conio_map_colour.asm | 60 +++--- libsrc/target/aquarius/stdio/conio_vars.asm | 27 ++- .../target/aquarius/stdio/generic_console.asm | 193 +++++------------- .../aquarius/stdio/generic_console_attr.asm | 37 ++++ .../aquarius/stdio/generic_console_ioctl.asm | 122 +++++++++++ .../aquarius/stdio/generic_console_vpeek.asm | 26 +++ .../target/aquarius/stdio/get_video_base.asm | 38 ++++ .../target/aquarius/stdio/printc_BITMAP.asm | 83 ++++++++ libsrc/target/aquarius/stdio/printc_TEXT.asm | 23 +++ .../target/aquarius/stdio/scrollup_BITMAP.asm | 12 ++ .../target/aquarius/stdio/scrollup_TEXT.asm | 38 ++++ .../aquarius/stdio/set_default_palette.asm | 40 ++++ libsrc/target/aquarius/stdio/vpeek_BITMAP.asm | 38 ++++ libsrc/target/aquarius/stdio/vpeek_TEXT.asm | 19 ++ libsrc/target/aquarius/stdio/xypos_BITMAP.asm | 33 +++ libsrc/target/aquarius/stdio/xypos_TEXT.asm | 47 +++++ 25 files changed, 777 insertions(+), 186 deletions(-) create mode 100644 lib/target/aquarius/def/aqplus.def create mode 100644 lib/target/aquarius/def/aquarius.def create mode 100644 libsrc/target/aquarius/stdio/CRT_FONT.asm create mode 100644 libsrc/target/aquarius/stdio/cls_BITMAP.asm create mode 100644 libsrc/target/aquarius/stdio/cls_TEXT.asm create mode 100644 libsrc/target/aquarius/stdio/generic_console_attr.asm create mode 100644 libsrc/target/aquarius/stdio/generic_console_ioctl.asm create mode 100644 libsrc/target/aquarius/stdio/generic_console_vpeek.asm create mode 100644 libsrc/target/aquarius/stdio/get_video_base.asm create mode 100644 libsrc/target/aquarius/stdio/printc_BITMAP.asm create mode 100644 libsrc/target/aquarius/stdio/printc_TEXT.asm create mode 100644 libsrc/target/aquarius/stdio/scrollup_BITMAP.asm create mode 100644 libsrc/target/aquarius/stdio/scrollup_TEXT.asm create mode 100644 libsrc/target/aquarius/stdio/set_default_palette.asm create mode 100644 libsrc/target/aquarius/stdio/vpeek_BITMAP.asm create mode 100644 libsrc/target/aquarius/stdio/vpeek_TEXT.asm create mode 100644 libsrc/target/aquarius/stdio/xypos_BITMAP.asm create mode 100644 libsrc/target/aquarius/stdio/xypos_TEXT.asm diff --git a/lib/target/aquarius/classic/aquarius_crt0.asm b/lib/target/aquarius/classic/aquarius_crt0.asm index faa69315f7..4475a237db 100644 --- a/lib/target/aquarius/classic/aquarius_crt0.asm +++ b/lib/target/aquarius/classic/aquarius_crt0.asm @@ -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 diff --git a/lib/target/aquarius/classic/ram.asm b/lib/target/aquarius/classic/ram.asm index e69d77dca4..ae8d0e9ce8 100644 --- a/lib/target/aquarius/classic/ram.asm +++ b/lib/target/aquarius/classic/ram.asm @@ -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" diff --git a/lib/target/aquarius/classic/rom.asm b/lib/target/aquarius/classic/rom.asm index 4dea012f56..b69d544af9 100755 --- a/lib/target/aquarius/classic/rom.asm +++ b/lib/target/aquarius/classic/rom.asm @@ -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 @@ -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 diff --git a/lib/target/aquarius/def/aqplus.def b/lib/target/aquarius/def/aqplus.def new file mode 100644 index 0000000000..8fb8d4d704 --- /dev/null +++ b/lib/target/aquarius/def/aqplus.def @@ -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 + + + + + diff --git a/lib/target/aquarius/def/aquarius.def b/lib/target/aquarius/def/aquarius.def new file mode 100644 index 0000000000..0807269606 --- /dev/null +++ b/lib/target/aquarius/def/aquarius.def @@ -0,0 +1,6 @@ + + + + + defc DISPLAY = 12328 + defc COLOUR_MAP = DISPLAY + 1024 \ No newline at end of file diff --git a/libsrc/target/aquarius/aquarius.lst b/libsrc/target/aquarius/aquarius.lst index a2d79b8f2c..6f1e2f7af2 100644 --- a/libsrc/target/aquarius/aquarius.lst +++ b/libsrc/target/aquarius/aquarius.lst @@ -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 diff --git a/libsrc/target/aquarius/stdio/CRT_FONT.asm b/libsrc/target/aquarius/stdio/CRT_FONT.asm new file mode 100644 index 0000000000..a017feee2b --- /dev/null +++ b/libsrc/target/aquarius/stdio/CRT_FONT.asm @@ -0,0 +1,5 @@ + + +PUBLIC CRT_FONT + +defc CRT_FONT = 0 \ No newline at end of file diff --git a/libsrc/target/aquarius/stdio/cls_BITMAP.asm b/libsrc/target/aquarius/stdio/cls_BITMAP.asm new file mode 100644 index 0000000000..d6131517d6 --- /dev/null +++ b/libsrc/target/aquarius/stdio/cls_BITMAP.asm @@ -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 + + diff --git a/libsrc/target/aquarius/stdio/cls_TEXT.asm b/libsrc/target/aquarius/stdio/cls_TEXT.asm new file mode 100644 index 0000000000..75861fc9d9 --- /dev/null +++ b/libsrc/target/aquarius/stdio/cls_TEXT.asm @@ -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 diff --git a/libsrc/target/aquarius/stdio/conio_map_colour.asm b/libsrc/target/aquarius/stdio/conio_map_colour.asm index 2e046a046d..b3ba1a7936 100644 --- a/libsrc/target/aquarius/stdio/conio_map_colour.asm +++ b/libsrc/target/aquarius/stdio/conio_map_colour.asm @@ -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 @@ -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 diff --git a/libsrc/target/aquarius/stdio/conio_vars.asm b/libsrc/target/aquarius/stdio/conio_vars.asm index dc9a948566..93840e5315 100644 --- a/libsrc/target/aquarius/stdio/conio_vars.asm +++ b/libsrc/target/aquarius/stdio/conio_vars.asm @@ -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 + diff --git a/libsrc/target/aquarius/stdio/generic_console.asm b/libsrc/target/aquarius/stdio/generic_console.asm index e4f81fe54e..028044505b 100644 --- a/libsrc/target/aquarius/stdio/generic_console.asm +++ b/libsrc/target/aquarius/stdio/generic_console.asm @@ -1,156 +1,59 @@ ; -; -; Aquarius colours -; 0 = black -; 1 = red -; 2 = green -; 3 = yellow -; 4 = blue -; 5 = violet -; 6 = cyan -; 7 = white -; 8 = light grey -; 9 = blue green -; 10 = magenta -; 11 = dark blue -; 12 = light yellow -; 13 = light green -; 14 = orange -; 15 = dark gray - - - SECTION code_clib - - PUBLIC generic_console_cls - PUBLIC generic_console_vpeek - PUBLIC generic_console_scrollup - PUBLIC generic_console_printc - PUBLIC generic_console_ioctl - PUBLIC generic_console_set_ink - PUBLIC generic_console_set_paper - PUBLIC generic_console_set_attribute - - EXTERN CONSOLE_COLUMNS - EXTERN CONSOLE_ROWS - EXTERN __aquarius_attr - EXTERN conio_map_colour - - defc DISPLAY = 12328 - defc COLOUR_MAP = DISPLAY + 1024 - - INCLUDE "ioctl.def" - PUBLIC CLIB_GENCON_CAPS - defc CLIB_GENCON_CAPS = CAP_GENCON_FG_COLOUR | CAP_GENCON_BG_COLOUR - -generic_console_ioctl: - scf -generic_console_set_attribute: - ret - -generic_console_set_ink: - call conio_map_colour - and 15 - rla - rla - rla - rla - ld e,a - ld a,(__aquarius_attr) - and @00001111 - or e - ld (__aquarius_attr),a - ret - - -generic_console_set_paper: - call conio_map_colour - and 15 - ld e,a - ld a,(__aquarius_attr) - and @11110000 - or e - ld (__aquarius_attr),a - ret + + + + SECTION code_clib + + PUBLIC generic_console_cls + PUBLIC generic_console_scrollup + PUBLIC generic_console_printc + + EXTERN printc_BITMAP + EXTERN printc_TEXT + EXTERN cls_BITMAP + EXTERN cls_TEXT + EXTERN scrollup_BITMAP + EXTERN scrollup_TEXT + + EXTERN __aquarius_mode + + + + + generic_console_cls: - 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 + ld hl,__aquarius_mode + bit 0,(hl) + push hl + call nz,cls_TEXT + pop hl + bit 2,(hl) + call nz,cls_BITMAP + ret + + ; c = x ; b = y -; a = character to print +; a = d = character to print ; e = raw generic_console_printc: - call xypos - ld (hl),a - inc h - inc h - inc h - inc h - ld a,(__aquarius_attr) - ld (hl),a - ret - - -;Entry: c = x, -; b = y -;Exit: nc = success -; a = character, -; c = failure -generic_console_vpeek: - call xypos - ld a,(hl) - and a - ret - - -xypos: - ld hl,DISPLAY - CONSOLE_COLUMNS - ld de,CONSOLE_COLUMNS - inc b -generic_console_printc_1: - add hl,de - djnz generic_console_printc_1 -generic_console_printc_3: - add hl,bc ;hl now points to address in display - ret + ld hl,__aquarius_mode + bit 0,(hl) + jp nz,printc_TEXT + bit 2,(hl) + jp nz,printc_BITMAP + ret -generic_console_scrollup: - push de - push bc - ld hl, DISPLAY + CONSOLE_COLUMNS - ld de, DISPLAY - ld bc,+ ((CONSOLE_COLUMNS) * (CONSOLE_ROWS-1)) - ldir - ex de,hl - ld b,CONSOLE_COLUMNS -generic_console_scrollup_3: - ld (hl),32 - inc hl - djnz generic_console_scrollup_3 - ld hl, COLOUR_MAP + CONSOLE_COLUMNS - ld de, COLOUR_MAP - ld bc,+ ((CONSOLE_COLUMNS) * (CONSOLE_ROWS-1)) - ldir - ex de,hl - ld b,CONSOLE_COLUMNS - ld a,(__aquarius_attr) -generic_console_scrollup_4: - ld (hl),a - inc hl - djnz generic_console_scrollup_4 - pop bc - pop de - ret + +generic_console_scrollup: +jp scrollup_TEXT + ld hl,__aquarius_mode + bit 0,(hl) + jp nz,scrollup_TEXT + bit 2,(hl) + jp nz,scrollup_BITMAP + ret diff --git a/libsrc/target/aquarius/stdio/generic_console_attr.asm b/libsrc/target/aquarius/stdio/generic_console_attr.asm new file mode 100644 index 0000000000..ad6c66199d --- /dev/null +++ b/libsrc/target/aquarius/stdio/generic_console_attr.asm @@ -0,0 +1,37 @@ + +SECTION code_clib +PUBLIC generic_console_set_ink +PUBLIC generic_console_set_paper +PUBLIC generic_console_set_attribute + +EXTERN conio_map_colour +EXTERN __aquarius_attr + + + + +generic_console_set_ink: + call conio_map_colour + and 15 + rla + rla + rla + rla + ld e,a + ld a,(__aquarius_attr) + and @00001111 + or e + ld (__aquarius_attr),a +generic_console_set_attribute: + ret + + +generic_console_set_paper: + call conio_map_colour + and 15 + ld e,a + ld a,(__aquarius_attr) + and @11110000 + or e + ld (__aquarius_attr),a + ret diff --git a/libsrc/target/aquarius/stdio/generic_console_ioctl.asm b/libsrc/target/aquarius/stdio/generic_console_ioctl.asm new file mode 100644 index 0000000000..ab885ba4ee --- /dev/null +++ b/libsrc/target/aquarius/stdio/generic_console_ioctl.asm @@ -0,0 +1,122 @@ + + + MODULE generic_console_ioctl + PUBLIC generic_console_ioctl + + SECTION code_clib + INCLUDE "ioctl.def" + INCLUDE "target/aquarius/def/aqplus.def" + + EXTERN generic_console_cls + EXTERN __aquarius_mode + EXTERN __aquarius_video_base + EXTERN __aquarius_pcg_pagein + EXTERN __aquarius_video_pagein + EXTERN __aquarius_video_pageout + + EXTERN generic_console_font32 + EXTERN generic_console_udg32 + EXTERN generic_console_caps + + EXTERN CLIB_AQUARIUS_PLUS + EXTERN CLIB_VIDEO_PAGE_PORT + + + PUBLIC CLIB_GENCON_CAPS + defc CLIB_GENCON_CAPS = CAP_GENCON_FG_COLOUR | CAP_GENCON_BG_COLOUR + ; For AQ+ we have different values + defc CLIB_GENCON_CAPS_TEXT = CAP_GENCON_CUSTOM_FONT | CAP_GENCON_UDGS | CAP_GENCON_FG_COLOUR | CAP_GENCON_BG_COLOUR + defc CLIB_GENCON_CAPS_BITMAP = CAP_GENCON_CUSTOM_FONT | CAP_GENCON_UDGS | CAP_GENCON_FG_COLOUR | CAP_GENCON_BG_COLOUR | CAP_GENCON_INVERSE | CAP_GENCON_BOLD | CAP_GENCON_UNDERLINE + + +; a = ioctl +; de = arg +generic_console_ioctl: + ; Check to see if we're meant to suppport AQ+ + ld c,CLIB_AQUARIUS_PLUS + rr c + ccf + ret c + ex de,hl + ld e,(hl) ;de = where we point to + inc hl + ld d,(hl) + cp IOCTL_GENCON_SET_UDGS + jr nz,ck_font + ld (generic_console_udg32),de + call __aquarius_pcg_pagein + ld hl,(__aquarius_video_base) + ld bc,128 * 8 + add hl,bc + ex de,hl + ldir + call __aquarius_video_pageout + and a + ret +ck_font: + cp IOCTL_GENCON_SET_FONT32 + jr nz,ck_mode + ld (generic_console_font32),de + call __aquarius_pcg_pagein + ld hl,(__aquarius_video_base) + ld bc,32 * 8 + add hl,bc + ld bc,96 * 8 + ex de,hl + ldir + call __aquarius_video_pageout +success: + and a + ret + + +ck_mode: + cp IOCTL_GENCON_SET_MODE + jr nz,failure + ld a,e + ; VCTRL_MODE_OFF = (0 << 1), + ; VCTRL_TEXT_ENABLE = (1 << 0), + ; VCTRL_MODE_TILEMAP = (1 << 1), + ; VCTRL_MODE_BITMAP = (2 << 1), + ; VCTRL_MODE_MASK = (3 << 1), + ; VCTRL_SPRITES_ENABLE = (1 << 3), + ; VCTRL_TEXT_PRIORITY = (1 << 4), + ; 1 = mode 0 = text 40x25 + ; 2 = mode 1 - 64x32 tilemap + ; 3 = mode 2 = hires 320x200 + ; +8 = sprites enable + ; +16 = text priority + ; + ; If text is enabled, we preferentially print to there + ; + + ld (__aquarius_mode),a + out (PORT_VCTRL),a + ld c,CLIB_GENCON_CAPS_TEXT + bit 1,a + jr z,set_caps + ld c,CLIB_GENCON_CAPS_BITMAP +set_caps: + ld a,c + ld (generic_console_caps),a + call generic_console_cls + and a + ret +failure: + scf + ret + + + SECTION code_crt_init + + EXTERN set_default_palette + + ; On an Aquarius+ we modify the caps so that we can define the font + ld c,CLIB_AQUARIUS_PLUS + rr c + jr nc,not_plus + ld a,CLIB_GENCON_CAPS_TEXT + ld (generic_console_caps),a + call set_default_palette +not_plus: + diff --git a/libsrc/target/aquarius/stdio/generic_console_vpeek.asm b/libsrc/target/aquarius/stdio/generic_console_vpeek.asm new file mode 100644 index 0000000000..658c3dca93 --- /dev/null +++ b/libsrc/target/aquarius/stdio/generic_console_vpeek.asm @@ -0,0 +1,26 @@ + + + +SECTION code_clib + +PUBLIC generic_console_vpeek + +EXTERN vpeek_TEXT +EXTERN vpeek_BITMAP + +EXTERN __aquarius_mode + +;Entry: c = x, +; b = y +;Exit: nc = success +; a = character, +; c = failure +generic_console_vpeek: + ld hl,__aquarius_mode + bit 0,(hl) + jp nz,vpeek_TEXT + bit 2,(hl) + jp nz,vpeek_BITMAP + ret + + diff --git a/libsrc/target/aquarius/stdio/get_video_base.asm b/libsrc/target/aquarius/stdio/get_video_base.asm new file mode 100644 index 0000000000..afdae37321 --- /dev/null +++ b/libsrc/target/aquarius/stdio/get_video_base.asm @@ -0,0 +1,38 @@ + + +SECTION code_clib + +PUBLIC __aquarius_video_pagein +PUBLIC __aquarius_video_pageout +PUBLIC __aquarius_pcg_pagein +EXTERN CLIB_VIDEO_PAGE_PORT + +; Page in the video RAM for bitmap mode +__aquarius_video_pagein: + pop hl + in a,(CLIB_VIDEO_PAGE_PORT) + push af + ld a,20 + out (CLIB_VIDEO_PAGE_PORT),a + push hl + ret + +; Page in the PCG page for setting the font for text mode +__aquarius_pcg_pagein: + pop hl + in a,(CLIB_VIDEO_PAGE_PORT) + push af + ld a,21 + out (CLIB_VIDEO_PAGE_PORT),a + push hl + ret + +; Restore paging +__aquarius_video_pageout: + pop hl + pop af + out (CLIB_VIDEO_PAGE_PORT),a + push hl + ret + + diff --git a/libsrc/target/aquarius/stdio/printc_BITMAP.asm b/libsrc/target/aquarius/stdio/printc_BITMAP.asm new file mode 100644 index 0000000000..c67c85b657 --- /dev/null +++ b/libsrc/target/aquarius/stdio/printc_BITMAP.asm @@ -0,0 +1,83 @@ + + +SECTION code_clib + +PUBLIC printc_BITMAP + + +EXTERN xypos_BITMAP +EXTERN xypos_BITMAP_ATTR + +EXTERN generic_console_font32 +EXTERN generic_console_udg32 +EXTERN generic_console_flags +EXTERN __aquarius_attr + +EXTERN __aquarius_video_pagein +EXTERN __aquarius_video_pageout + +; b = y +; c = x +; a=d = character to print +; e = raw mode (ignored) +printc_BITMAP: + call __aquarius_video_pagein + push bc + ld l,d + ld h,0 + ld de,(generic_console_font32) + bit 7,l + jr z,not_udg + res 7,l ;take off 128 + ld de,(generic_console_udg32) + inc d ;We decrement later +not_udg: + add hl,hl + add hl,hl + add hl,hl + add hl,de + dec h ; -32 characters + ex de,hl ; de = font + call xypos_BITMAP + ld a,(generic_console_flags) + rlca + sbc a,a + ld c,a ;x = 0 / 255 + ld b,8 +hires_printc_1: + push bc + ld a,(generic_console_flags) + bit 4,a + ld a,(de) + ld b,a + jr z,no_32_bold + rrca + or b +no_32_bold: + xor c + ld (hl),a + inc de + ld bc,40 + add hl,bc +no_overflow: + pop bc + djnz hires_printc_1 + ; Consider underline + ld a,(generic_console_flags) + bit 3,a + jr z,do_attribute + ld bc,-40 + add hl,bc + ld (hl),255 + ; Now we need to handle the attribute +do_attribute: + pop bc + call xypos_BITMAP_ATTR + ld a,(__aquarius_attr) + ld (hl),a + + call __aquarius_video_pageout + ret + + + diff --git a/libsrc/target/aquarius/stdio/printc_TEXT.asm b/libsrc/target/aquarius/stdio/printc_TEXT.asm new file mode 100644 index 0000000000..c1b15c2d1b --- /dev/null +++ b/libsrc/target/aquarius/stdio/printc_TEXT.asm @@ -0,0 +1,23 @@ + +SECTION code_clib + +PUBLIC printc_TEXT + +EXTERN xypos_TEXT +EXTERN __aquarius_attr + + +; c = x +; b = y +; a = d = character to print +; e = raw +printc_TEXT: + call xypos_TEXT + ld (hl),d + inc h + inc h + inc h + inc h + ld a,(__aquarius_attr) + ld (hl),a + ret diff --git a/libsrc/target/aquarius/stdio/scrollup_BITMAP.asm b/libsrc/target/aquarius/stdio/scrollup_BITMAP.asm new file mode 100644 index 0000000000..4250d46b7a --- /dev/null +++ b/libsrc/target/aquarius/stdio/scrollup_BITMAP.asm @@ -0,0 +1,12 @@ + +SECTION code_clib + +PUBLIC scrollup_BITMAP + +scrollup_BITMAP: + push de + push bc + + pop bc + pop de + ret diff --git a/libsrc/target/aquarius/stdio/scrollup_TEXT.asm b/libsrc/target/aquarius/stdio/scrollup_TEXT.asm new file mode 100644 index 0000000000..e2d4677306 --- /dev/null +++ b/libsrc/target/aquarius/stdio/scrollup_TEXT.asm @@ -0,0 +1,38 @@ + +SECTION code_clib + +PUBLIC scrollup_TEXT + +INCLUDE "target/aquarius/def/aquarius.def" + +EXTERN CONSOLE_COLUMNS +EXTERN CONSOLE_ROWS +EXTERN __aquarius_attr + +scrollup_TEXT: + push de + push bc + ld hl, DISPLAY + CONSOLE_COLUMNS + ld de, DISPLAY + ld bc,+ ((CONSOLE_COLUMNS) * (CONSOLE_ROWS-1)) + ldir + ex de,hl + ld b,CONSOLE_COLUMNS +generic_console_scrollup_3: + ld (hl),32 + inc hl + djnz generic_console_scrollup_3 + ld hl, COLOUR_MAP + CONSOLE_COLUMNS + ld de, COLOUR_MAP + ld bc,+ ((CONSOLE_COLUMNS) * (CONSOLE_ROWS-1)) + ldir + ex de,hl + ld b,CONSOLE_COLUMNS + ld a,(__aquarius_attr) +generic_console_scrollup_4: + ld (hl),a + inc hl + djnz generic_console_scrollup_4 + pop bc + pop de + ret diff --git a/libsrc/target/aquarius/stdio/set_default_palette.asm b/libsrc/target/aquarius/stdio/set_default_palette.asm new file mode 100644 index 0000000000..d173547cfb --- /dev/null +++ b/libsrc/target/aquarius/stdio/set_default_palette.asm @@ -0,0 +1,40 @@ + +SECTION code_clib + +INCLUDE "target/aquarius/def/aqplus.def" + +PUBLIC set_default_palette + + +; Set the default palette for bitmap mode +; We use the same as for text mode +set_default_palette: + ld hl,palette + xor a +next: + push af + rlca + or @00100000 ;Palette 1, set GB + ld b,a + out (PORT_VPALSEL),a + ld a,(hl) + inc hl + out (PORT_VPALDATA),a + ld a,b + or @00000001 ;Set R + out (PORT_VPALSEL),a + ld a,(hl) + inc hl + out (PORT_VPALDATA),a + pop af + inc a + cp 16 + jr nz,next + ret + + +SECTION rodata_clib + +palette: + defw 0x111, 0xF11, 0x1F1, 0xFF1, 0x22E, 0xF1F, 0x3CC, 0xFFF + defw 0xCCC, 0x3BB, 0xC2C, 0x419, 0xFF7, 0x2D4, 0xB22, 0x333 \ No newline at end of file diff --git a/libsrc/target/aquarius/stdio/vpeek_BITMAP.asm b/libsrc/target/aquarius/stdio/vpeek_BITMAP.asm new file mode 100644 index 0000000000..c69fa457a6 --- /dev/null +++ b/libsrc/target/aquarius/stdio/vpeek_BITMAP.asm @@ -0,0 +1,38 @@ + + SECTION code_clib + + PUBLIC vpeek_BITMAP + EXTERN xypos_BITMAP + EXTERN __aquarius_video_pagein + EXTERN __aquarius_video_pageout + EXTERN vpeek_screendollar + + +;Entry: c = x, +; b = y +;Exit: nc = success +; a = character, +; c = failure +vpeek_BITMAP: + ld hl,-8 + add hl,sp ;de = screen, hl = buffer, bc = coords + ld sp,hl + push hl ;Save buffer + ex de,hl ;get it into de + call __aquarius_video_pagein ;uses hl + call xypos_BITMAP + ld b,8 +vpeek_1: + ld a,(hl) + ld (de),a + inc de + ld a,l + add 40 + ld l,a + jr nc,no_overflow + inc h +no_overflow: + djnz vpeek_1 + call __aquarius_video_pageout + jp vpeek_screendollar + diff --git a/libsrc/target/aquarius/stdio/vpeek_TEXT.asm b/libsrc/target/aquarius/stdio/vpeek_TEXT.asm new file mode 100644 index 0000000000..f81dbbdc43 --- /dev/null +++ b/libsrc/target/aquarius/stdio/vpeek_TEXT.asm @@ -0,0 +1,19 @@ + +SECTION code_clib + +PUBLIC vpeek_TEXT + +EXTERN xypos_TEXT + + + +;Entry: c = x, +; b = y +;Exit: nc = success +; a = character, +; c = failure +vpeek_TEXT: + call xypos_TEXT + ld a,(hl) + and a + ret diff --git a/libsrc/target/aquarius/stdio/xypos_BITMAP.asm b/libsrc/target/aquarius/stdio/xypos_BITMAP.asm new file mode 100644 index 0000000000..8a05e1fa07 --- /dev/null +++ b/libsrc/target/aquarius/stdio/xypos_BITMAP.asm @@ -0,0 +1,33 @@ + +SECTION code_clib + +PUBLIC xypos_BITMAP + +EXTERN __aquarius_video_base + + +; Entry: +; b = row +; c = column +; Exit: +; hl = address +xypos_BITMAP: + ld a,c ;save column for later + ld l,b + ld h,0 + add hl,hl ;*2 + add hl,hl ;*4 + add hl,hl ;*8 + add hl,hl ;*16 + add hl,hl ;*32 + add hl,hl ;*64 + ld bc,hl + add hl,hl ;*128 + add hl,hl ;*256 + add hl,bc ;*320 + ld c,a ;Add column + ld b,0 + add hl,bc + ld bc,(__aquarius_video_base) + add hl,bc + ret diff --git a/libsrc/target/aquarius/stdio/xypos_TEXT.asm b/libsrc/target/aquarius/stdio/xypos_TEXT.asm new file mode 100644 index 0000000000..ed7aae04a2 --- /dev/null +++ b/libsrc/target/aquarius/stdio/xypos_TEXT.asm @@ -0,0 +1,47 @@ + +SECTION code_clib + +PUBLIC xypos_TEXT +PUBLIC xypos_BITMAP_ATTR + +EXTERN CONSOLE_COLUMNS + +INCLUDE "target/aquarius/def/aquarius.def" + +EXTERN __aquarius_video_base + +; Entry: +; b = row +; c = column +; Exit: +; hl = address +xypos_TEXT: + call xypos + ld bc,DISPLAY + add hl,bc + ret + +xypos_BITMAP_ATTR: + call xypos + set 5,h ;Add $2000 + ld bc,(__aquarius_video_base) + add hl,bc + ret + +xypos: + ld a,c ;save column + ld l,b + ld h,0 + add hl,hl ;*2 + ld bc,hl + add hl,hl ;*4 + add hl,hl ;*8 + add hl,bc ;*10 + add hl,hl ;*20 + add hl,hl ;*40 + ld c,a ;add column (b=0 already) + ld b,0 + add hl,bc + ret + + \ No newline at end of file