From a3d8829be92032d262cbea686c400a098e9e5242 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Fri, 17 Mar 2017 21:42:51 +0100 Subject: [PATCH] Creativison changes. This change includes some cleanups, removal of mainargs.s (game console programs never have arguments), and a workaround for a problem I'm seeing. The problem is that sometimes (in fact, more often than not) the clrscr() call in testcode/lib/joy-test.c writes some garbage chars on the screen (most often a "P"). Could be my hardware (I haven't seen it on MAME), but to me the root cause is still unknown. --- asminc/creativision.inc | 7 ++++--- cfg/creativision.cfg | 2 +- libsrc/creativision/clrscr.s | 6 +++--- libsrc/creativision/cputc.s | 6 +++--- libsrc/creativision/crt0.s | 15 ++++++++++----- libsrc/creativision/mainargs.s | 22 ---------------------- 6 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 libsrc/creativision/mainargs.s diff --git a/asminc/creativision.inc b/asminc/creativision.inc index 83a63ba07..49d55a342 100644 --- a/asminc/creativision.inc +++ b/asminc/creativision.inc @@ -10,10 +10,10 @@ CURSOR_X = $3C CURSOR_Y = $3D ;** VDP -VDP_CONTROL_W = $3001 -VDP_DATA_W = $3000 -VDP_STATUS_R = $2001 VDP_DATA_R = $2000 +VDP_STATUS_R = $2001 +VDP_DATA_W = $3000 +VDP_CONTROL_W = $3001 ;** PIA PIA0_DATA = $1000 @@ -58,3 +58,4 @@ JOY_NNW = $4A BIOS_IRQ1_ADDR = $FF3F BIOS_IRQ2_ADDR = $FF52 BIOS_NMI_RESET_ADDR = $F808 +BIOS_WRITE_VDP_REG = $FE1F diff --git a/cfg/creativision.cfg b/cfg/creativision.cfg index 06e39b36f..9e4ecd8ce 100644 --- a/cfg/creativision.cfg +++ b/cfg/creativision.cfg @@ -4,7 +4,7 @@ SYMBOLS { MEMORY { ZP: file = "", define = yes, start = $0020, size = $00E0; RAM: file = "", define = yes, start = $01FA, size = $0206; - ROM: file = %O, define = yes, start = $B000, size = $1000; + ROM: file = %O, define = yes, start = $B000, size = $1000, fill = yes, fillval = $FF; } SEGMENTS { ZEROPAGE: load = ZP, type = zp; diff --git a/libsrc/creativision/clrscr.s b/libsrc/creativision/clrscr.s index 9e7238345..3c4856446 100644 --- a/libsrc/creativision/clrscr.s +++ b/libsrc/creativision/clrscr.s @@ -18,7 +18,7 @@ _clrscr: lda #$50 ; VRAM offset high ($10 OR $40) sta VDP_CONTROL_W - lda #$C0 ; Space from ROM setup + lda #$40 ; Space char from ROM setup ldx #0 ldy #3 @@ -34,8 +34,8 @@ L1: sta VDP_DATA_W lda #0 sta CURSOR_X sta CURSOR_Y - sta SCREEN_PTR + sta SCREEN_PTR+1 rts diff --git a/libsrc/creativision/cputc.s b/libsrc/creativision/cputc.s index ff60494b9..437b738b2 100644 --- a/libsrc/creativision/cputc.s +++ b/libsrc/creativision/cputc.s @@ -96,8 +96,8 @@ BAD_CHAR: jmp plot ;----------------------------------------------------------------------------- -; Initialize the conio subsystem. Code goes into the INIT segment, which may -; be reused after startup. +; Initialize the conio subsystem. "INIT" segment is nothing special on the +; Creativision, it is part of the "ROM" memory. .segment "INIT" @@ -122,4 +122,4 @@ LL: lda boxchars,x bne LL cli - jmp plot + jmp plot diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s index 420ac71ef..5185ff237 100644 --- a/libsrc/creativision/crt0.s +++ b/libsrc/creativision/crt0.s @@ -31,9 +31,6 @@ entry: ldx #<__RAM_START__ - 1 txs - ; Start interrupts - cli - ; Clear the BSS data jsr zerobss @@ -49,13 +46,21 @@ entry: ; Call module constructors jsr initlib + ; enable vertical blank interrupts in the display controller + lda #$E0 ; 16K RAM, Active Display, Mode 1, VBI enabled + ldx #$01 ; Register 1 + jsr BIOS_WRITE_VDP_REG + + ; Start interrupts + cli + ; Call main() jsr callmain ; Call module destructors. This is also the _exit entry. _exit: jsr donelib - ; TODO: Replace with some sort of reset + ; A Creativision program isn't supposed to exit. loop: jmp loop ; ------------------------------------------------------------------------ @@ -81,7 +86,7 @@ irq2: jmp BIOS_IRQ2_ADDR ; VDP Setup ; This sets to Graphics Mode 1 .byte $00 ; Register 0 - .byte $E0 ; Register 1 16K RAM, Active Display, Mode 1, VBI enabled + .byte $C0 ; Register 1 16K RAM, Active Display, Mode 1, VBI disabled .byte $04 ; Register 2 Name Table at $1000 - $12FF .byte $60 ; Register 3 Colour Table at $1800 - $181F .byte $00 ; Register 4 Pattern Table at $0000 - $07FF diff --git a/libsrc/creativision/mainargs.s b/libsrc/creativision/mainargs.s deleted file mode 100644 index cda76d8d0..000000000 --- a/libsrc/creativision/mainargs.s +++ /dev/null @@ -1,22 +0,0 @@ -; -; Ullrich von Bassewitz, 2003-03-07 -; -; Setup arguments for main -; - - - .constructor initmainargs, 24 - .import __argc, __argv - - -;--------------------------------------------------------------------------- -; Get possible command-line arguments. Goes into the special INIT segment, -; which may be reused after the startup code is run - -.segment "INIT" - -.proc initmainargs - - rts - -.endproc