From 11be575b6dddeba424c0bf02d848f6dd143ada8d Mon Sep 17 00:00:00 2001 From: kym Date: Thu, 5 Dec 2013 11:40:44 +0000 Subject: [PATCH 01/11] Initial Creativision Import --- asminc/creativision.inc | 38 +++++++ include/creativision.h | 59 +++++++++++ libsrc/creativision/_scrsize.s | 15 +++ libsrc/creativision/boxchars.inc | 62 +++++++++++ libsrc/creativision/cclear.s | 29 ++++++ libsrc/creativision/cgetc.s | 17 +++ libsrc/creativision/chline.s | 24 +++++ libsrc/creativision/clrscr.s | 41 ++++++++ libsrc/creativision/color.s | 13 +++ libsrc/creativision/cputc.s | 125 ++++++++++++++++++++++ libsrc/creativision/ctype.s | 172 +++++++++++++++++++++++++++++++ libsrc/creativision/cvline.s | 29 ++++++ libsrc/creativision/gotox.s | 19 ++++ libsrc/creativision/gotoxy.s | 22 ++++ libsrc/creativision/gotoy.s | 19 ++++ libsrc/creativision/joy.s | 58 +++++++++++ libsrc/creativision/libref.s | 9 ++ libsrc/creativision/mainargs.s | 24 +++++ libsrc/creativision/psg.s | 68 ++++++++++++ libsrc/creativision/setcursor.s | 36 +++++++ libsrc/creativision/sysuname.s | 39 +++++++ libsrc/creativision/wherex.s | 19 ++++ libsrc/creativision/wherey.s | 19 ++++ 23 files changed, 956 insertions(+) create mode 100644 asminc/creativision.inc create mode 100644 include/creativision.h create mode 100644 libsrc/creativision/_scrsize.s create mode 100644 libsrc/creativision/boxchars.inc create mode 100644 libsrc/creativision/cclear.s create mode 100644 libsrc/creativision/cgetc.s create mode 100644 libsrc/creativision/chline.s create mode 100644 libsrc/creativision/clrscr.s create mode 100644 libsrc/creativision/color.s create mode 100644 libsrc/creativision/cputc.s create mode 100644 libsrc/creativision/ctype.s create mode 100644 libsrc/creativision/cvline.s create mode 100644 libsrc/creativision/gotox.s create mode 100644 libsrc/creativision/gotoxy.s create mode 100644 libsrc/creativision/gotoy.s create mode 100644 libsrc/creativision/joy.s create mode 100644 libsrc/creativision/libref.s create mode 100644 libsrc/creativision/mainargs.s create mode 100644 libsrc/creativision/psg.s create mode 100644 libsrc/creativision/setcursor.s create mode 100644 libsrc/creativision/sysuname.s create mode 100644 libsrc/creativision/wherex.s create mode 100644 libsrc/creativision/wherey.s diff --git a/asminc/creativision.inc b/asminc/creativision.inc new file mode 100644 index 000000000..624b65e8f --- /dev/null +++ b/asminc/creativision.inc @@ -0,0 +1,38 @@ +;* +;** VTech Creativision Definitions +;* + +;** Screen +SCREEN_ROWS = 24 +SCREEN_COLS = 32 +SCREEN_PTR = $3A +CURSOR_X = $3C +CURSOR_Y = $3D + +;** VDP +VDP_CONTROL_W = $3001 +VDP_DATA_W = $3000 +VDP_STATUS_R = $2001 +VDP_DATA_R = $2000 + +;** PIA +PIA0_DATA = $1000 +PIA0_STATUS = $1001 +PIA1_DATA = $1002 +PIA1_STATUS = $1003 + +;** General +CH_VLINE = 33 +CH_HLINE = 34 +CH_ULCORNER = 35 +CH_URCORNER = 36 +CH_LLCORNER = 37 +CH_LRCORNER = 38 + +;** I/O +ZP_KEYBOARD = $10 +ZP_JOY0_DIR = $11 +ZP_JOY1_DIR = $13 +ZP_JOY_LBUTTONS = $16 +ZP_JOY_RBUTTONS = $17 + diff --git a/include/creativision.h b/include/creativision.h new file mode 100644 index 000000000..adaa1caab --- /dev/null +++ b/include/creativision.h @@ -0,0 +1,59 @@ +/* CreatiVision Header */ + +#ifndef _CVISION_H + +#define _CVISION_H + +#define CH_VLINE 33 +#define CH_HLINE 34 +#define CH_ULCORNER 35 +#define CH_URCORNER 36 +#define CH_LLCORNER 37 +#define CH_LRCORNER 38 + +#define DYN_DRV 0 + +/* Colours - from TMS9918 */ +#define C_TRANSPARENT 0 +#define C_BLACK 1 +#define C_MED_GREEN 2 +#define C_LIGHT_GREEN 3 +#define C_DARK_BLUE 4 +#define C_LIGHT_BLUE 5 +#define C_DARK_RED 6 +#define C_CYAN 7 +#define C_MED_RED 8 +#define C_LIGHT_RED 9 +#define C_DARK_YELLOW 10 +#define C_LIGHT_YELLOW 11 +#define C_DARK_GREEN 12 +#define C_MAGENTA 13 +#define C_GREY 14 +#define C_WHITE 15 + +/* Joystick states */ +#define JOY_UP 5 +#define JOY_DOWN 1 +#define JOY_LEFT 7 +#define JOY_RIGHT 3 +#define JOY_LEFT_UP 6 +#define JOY_LEFT_DOWN 8 +#define JOY_RIGHT_UP 4 +#define JOY_RIGHT_DOWN 2 +#define JOY_LBUTTON 1 +#define JOY_RBUTTON 2 + +/* Joystick values */ +#define JOY_LEFT_DIR 1 +#define JOY_RIGHT_DIR 2 +#define JOY_LEFT_BUTTONS 3 +#define JOY_RIGHT_BUTTONS 4 + +/* Protos */ +void __fastcall__ psg_outb( unsigned char b ); +void __fastcall__ psg_delay( unsigned char b ); +void psg_silence( void ); +void __fastcall__ bios_playsound( void *a, unsigned char b); +unsigned char __fastcall__ joystate( unsigned char which ); + +#endif diff --git a/libsrc/creativision/_scrsize.s b/libsrc/creativision/_scrsize.s new file mode 100644 index 000000000..fdcc7fc60 --- /dev/null +++ b/libsrc/creativision/_scrsize.s @@ -0,0 +1,15 @@ +;* +;** _scrsize.s +;* + + .export screensize + + .include "creativision.inc" + +.proc screensize + + ldx #SCREEN_COLS + ldy #SCREEN_ROWS + rts + +.endproc diff --git a/libsrc/creativision/boxchars.inc b/libsrc/creativision/boxchars.inc new file mode 100644 index 000000000..0916d49ce --- /dev/null +++ b/libsrc/creativision/boxchars.inc @@ -0,0 +1,62 @@ +; Boxchars + +boxchars: + ; Vertical Line + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + + ; Horizontal Line + .byte 0 + .byte 0 + .byte 0 + .byte $ff + .byte 0 + .byte 0 + .byte 0 + .byte 0 + + ; Top Left + .byte 0 + .byte 0 + .byte 0 + .byte $1f + .byte $18 + .byte $18 + .byte $18 + .byte $18 + + ; Top Right + .byte 0 + .byte 0 + .byte 0 + .byte $F8 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + + ; Bottom Left + .byte $18 + .byte $18 + .byte $18 + .byte $1F + .byte 0 + .byte 0 + .byte 0 + .byte 0 + + ; Bottom Right + .byte $18 + .byte $18 + .byte $18 + .byte $F8 + .byte 0 + .byte 0 + .byte 0 + .byte 0 diff --git a/libsrc/creativision/cclear.s b/libsrc/creativision/cclear.s new file mode 100644 index 000000000..507c072bd --- /dev/null +++ b/libsrc/creativision/cclear.s @@ -0,0 +1,29 @@ +;* +;* void cclearxy (unsigned char x, unsigned char y, unsigned char length); +;* void cclear (unsigned char length); +;* + + .export _cclearxy, _cclear + .import popa, _gotoxy, cputdirect + .importzp tmp1 + +_cclearxy: + pha ; Save length + jsr popa ; get Y + jsr _gotoxy + pla + +_cclear: + cmp #0 ; Zero length? + beq L2 + sta tmp1 + +L1: + lda #$20 ; Space + jsr cputdirect + dec tmp1 + bne L1 + +L2: rts + + diff --git a/libsrc/creativision/cgetc.s b/libsrc/creativision/cgetc.s new file mode 100644 index 000000000..f1e89942a --- /dev/null +++ b/libsrc/creativision/cgetc.s @@ -0,0 +1,17 @@ +;* cgetc + + .export _cgetc + .include "creativision.inc" + +_cgetc: + lda #$80 + +L1: + bit ZP_KEYBOARD + bpl L1 + + lda ZP_KEYBOARD + and #$7f + rts + + diff --git a/libsrc/creativision/chline.s b/libsrc/creativision/chline.s new file mode 100644 index 000000000..c206180e0 --- /dev/null +++ b/libsrc/creativision/chline.s @@ -0,0 +1,24 @@ +;* void chlinexy (unsigned char x, unsigned char y, unsigned char length); +;* void chline (unsigned char length); + + .export _chlinexy, _chline + .import popa, _gotoxy, cputdirect + .importzp tmp1 + + .include "creativision.inc" + +_chlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length + +_chline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #CH_HLINE ; Horizontal line, screen code + jsr cputdirect ; Direct output + dec tmp1 + bne L1 +L9: rts diff --git a/libsrc/creativision/clrscr.s b/libsrc/creativision/clrscr.s new file mode 100644 index 000000000..ef800a9bd --- /dev/null +++ b/libsrc/creativision/clrscr.s @@ -0,0 +1,41 @@ +;* +;* clrscr +;* +;* NB: All screen functions assume Graphics Mode 1 in a default configuration. +;* Therefore, this is hard coded to use $1000-$12FF as screen VRAM. + + .export _clrscr + .include "creativision.inc" + +_clrscr: + + sei ; Disable interrupts. Default INT handler reads VDP_STATUS + ; and would lose any setup done here. + + lda #$00 ; VRAM offset low + sta VDP_CONTROL_W + + lda #$50 ; VRAM offset high ($10 OR $40) + sta VDP_CONTROL_W + + lda #$C0 ; Space from ROM setup + + ldx #0 + ldy #3 + +L1: sta VDP_DATA_W + inx + bne L1 + dey + bne L1 + + cli ; Let interrupts go again + + lda #0 + sta CURSOR_X + sta CURSOR_Y + sta SCREEN_PTR + + rts diff --git a/libsrc/creativision/color.s b/libsrc/creativision/color.s new file mode 100644 index 000000000..b6fd360b4 --- /dev/null +++ b/libsrc/creativision/color.s @@ -0,0 +1,13 @@ +;* +;* unsigned char __fastcall__ textcolor (unsigned char color); +;* unsigned char __fastcall__ bgcolor (unsigned char color); +;* unsigned char __fastcall__ bordercolor (unsigned char color); +;* + + .export _textcolor, _bgcolor, _bordercolor + .import return0 + .include "creativision.inc" + +_bordercolor = return0; +_textcolor = return0; +_bgcolor = return0; diff --git a/libsrc/creativision/cputc.s b/libsrc/creativision/cputc.s new file mode 100644 index 000000000..902caf277 --- /dev/null +++ b/libsrc/creativision/cputc.s @@ -0,0 +1,125 @@ +; +; Written by Groepaz/Hitmen +; Cleanup by Ullrich von Bassewitz +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + + .export _cputcxy, _cputc, cputdirect, putchar + .export newline + .constructor initconio + .import popa, _gotoxy + .import setcursor + + .importzp tmp3,tmp4 + + .include "creativision.inc" + .include "boxchars.inc" + +;----------------------------------------------------------------------------- + +.code + +_cputcxy: + pha ; Save C + jsr popa ; Get Y + jsr _gotoxy ; Set cursor, drop x + pla ; Restore C + +; Plot a character - also used as internal function + +_cputc: cmp #$0d ; CR? + bne L1 + lda #0 + sta CURSOR_X + beq plot ; Recalculate pointers + +L1: cmp #$0a ; LF? + beq newline ; Recalculate pointers + +; Printable char of some sort + +cputdirect: + jsr putchar ; Write the character to the screen + +; Advance cursor position + +advance: + ldy CURSOR_X + iny + cpy #SCREEN_COLS + bne L3 + inc CURSOR_Y ; new line + ldy #0 ; + cr +L3: sty CURSOR_X + jmp plot + +newline: + inc CURSOR_Y + +; Set cursor position, calculate RAM pointers + +plot: ldy CURSOR_X + ldx CURSOR_Y + jmp setcursor ; Set the new cursor + + +; Write one character to the screen without doing anything else, return X +; position in Y + +putchar: + cmp #$5B + bcc IS_UPPER + + clc + sbc #$1F + +IS_UPPER: + cmp #$20 + bcc BAD_CHAR + + pha + lda SCREEN_PTR + sei + sta VDP_CONTROL_W + lda SCREEN_PTR+1 + ora #$40 + sta VDP_CONTROL_W + pla + clc + adc #160 + sta VDP_DATA_W + cli + +BAD_CHAR: + jmp plot + +;----------------------------------------------------------------------------- +; Initialize the conio subsystem. Code goes into the INIT segment, which may +; be reused after startup. + +.segment "INIT" + +initconio: + lda #$0 + sta SCREEN_PTR + lda #$10 + sta SCREEN_PTR+1 + + ; Copy box characters to slot + sei + lda #08 + sta VDP_CONTROL_W + lda #$46 + sta VDP_CONTROL_W + ldx #0 +LL: + lda boxchars,x + sta VDP_DATA_W + inx + cpx #48 + bne LL + + cli + jmp plot diff --git a/libsrc/creativision/ctype.s b/libsrc/creativision/ctype.s new file mode 100644 index 000000000..6e0ab1785 --- /dev/null +++ b/libsrc/creativision/ctype.s @@ -0,0 +1,172 @@ +; +; Ullrich von Bassewitz, 02.06.1998 +; +; Character specification table. +; + +; The tables are readonly, put them into the rodata segment + +.rodata + +; The following 256 byte wide table specifies attributes for the isxxx type +; of functions. Doing it by a table means some overhead in space, but it +; has major advantages: +; +; * It is fast. If it were'nt for the slow parameter passing of cc65, one +; could even define macros for the isxxx functions (this is usually +; done on other platforms). +; +; * It is highly portable. The only unportable part is the table itself, +; all real code goes into the common library. +; +; * We save some code in the isxxx functions. +; +; +; Bit assignments: +; +; 0 - Lower case char +; 1 - Upper case char +; 2 - Numeric digit +; 3 - Hex digit (both, lower and upper) +; 4 - Control character +; 5 - The space character itself +; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v') +; 7 - Space or tab character + + .export __ctype + +__ctype: + +.repeat 2 ; 2 times for normal and inverted + + .byte $10 ; 0/00 ___ctrl_@___ + .byte $10 ; 1/01 ___ctrl_A___ + .byte $10 ; 2/02 ___ctrl_B___ + .byte $10 ; 3/03 ___ctrl_C___ + .byte $10 ; 4/04 ___ctrl_D___ + .byte $10 ; 5/05 ___ctrl_E___ + .byte $10 ; 6/06 ___ctrl_F___ + .byte $10 ; 7/07 ___ctrl_G___ + .byte $10 ; 8/08 ___ctrl_H___ + .byte $D0 ; 9/09 ___ctrl_I___ + .byte $50 ; 10/0a ___ctrl_J___ + .byte $50 ; 11/0b ___ctrl_K___ + .byte $50 ; 12/0c ___ctrl_L___ + .byte $50 ; 13/0d ___ctrl_M___ + .byte $10 ; 14/0e ___ctrl_N___ + .byte $10 ; 15/0f ___ctrl_O___ + .byte $10 ; 16/10 ___ctrl_P___ + .byte $10 ; 17/11 ___ctrl_Q___ + .byte $10 ; 18/12 ___ctrl_R___ + .byte $10 ; 19/13 ___ctrl_S___ + .byte $10 ; 20/14 ___ctrl_T___ + .byte $10 ; 21/15 ___ctrl_U___ + .byte $10 ; 22/16 ___ctrl_V___ + .byte $10 ; 23/17 ___ctrl_W___ + .byte $10 ; 24/18 ___ctrl_X___ + .byte $10 ; 25/19 ___ctrl_Y___ + .byte $10 ; 26/1a ___ctrl_Z___ + .byte $10 ; 27/1b ___ctrl_[___ + .byte $10 ; 28/1c ___ctrl_\___ + .byte $10 ; 29/1d ___ctrl_]___ + .byte $10 ; 30/1e ___ctrl_^___ + .byte $10 ; 31/1f ___ctrl_____ + .byte $A0 ; 32/20 ___SPACE___ + .byte $00 ; 33/21 _____!_____ + .byte $00 ; 34/22 _____"_____ + .byte $00 ; 35/23 _____#_____ + .byte $00 ; 36/24 _____$_____ + .byte $00 ; 37/25 _____%_____ + .byte $00 ; 38/26 _____&_____ + .byte $00 ; 39/27 _____'_____ + .byte $00 ; 40/28 _____(_____ + .byte $00 ; 41/29 _____)_____ + .byte $00 ; 42/2a _____*_____ + .byte $00 ; 43/2b _____+_____ + .byte $00 ; 44/2c _____,_____ + .byte $00 ; 45/2d _____-_____ + .byte $00 ; 46/2e _____._____ + .byte $00 ; 47/2f _____/_____ + .byte $0C ; 48/30 _____0_____ + .byte $0C ; 49/31 _____1_____ + .byte $0C ; 50/32 _____2_____ + .byte $0C ; 51/33 _____3_____ + .byte $0C ; 52/34 _____4_____ + .byte $0C ; 53/35 _____5_____ + .byte $0C ; 54/36 _____6_____ + .byte $0C ; 55/37 _____7_____ + .byte $0C ; 56/38 _____8_____ + .byte $0C ; 57/39 _____9_____ + .byte $00 ; 58/3a _____:_____ + .byte $00 ; 59/3b _____;_____ + .byte $00 ; 60/3c _____<_____ + .byte $00 ; 61/3d _____=_____ + .byte $00 ; 62/3e _____>_____ + .byte $00 ; 63/3f _____?_____ + + .byte $00 ; 64/40 _____@_____ + .byte $0A ; 65/41 _____A_____ + .byte $0A ; 66/42 _____B_____ + .byte $0A ; 67/43 _____C_____ + .byte $0A ; 68/44 _____D_____ + .byte $0A ; 69/45 _____E_____ + .byte $0A ; 70/46 _____F_____ + .byte $02 ; 71/47 _____G_____ + .byte $02 ; 72/48 _____H_____ + .byte $02 ; 73/49 _____I_____ + .byte $02 ; 74/4a _____J_____ + .byte $02 ; 75/4b _____K_____ + .byte $02 ; 76/4c _____L_____ + .byte $02 ; 77/4d _____M_____ + .byte $02 ; 78/4e _____N_____ + .byte $02 ; 79/4f _____O_____ + .byte $02 ; 80/50 _____P_____ + .byte $02 ; 81/51 _____Q_____ + .byte $02 ; 82/52 _____R_____ + .byte $02 ; 83/53 _____S_____ + .byte $02 ; 84/54 _____T_____ + .byte $02 ; 85/55 _____U_____ + .byte $02 ; 86/56 _____V_____ + .byte $02 ; 87/57 _____W_____ + .byte $02 ; 88/58 _____X_____ + .byte $02 ; 89/59 _____Y_____ + .byte $02 ; 90/5a _____Z_____ + .byte $00 ; 91/5b _____[_____ + .byte $00 ; 92/5c _____\_____ + .byte $00 ; 93/5d _____]_____ + .byte $00 ; 94/5e _____^_____ + .byte $00 ; 95/5f _UNDERLINE_ + .byte $00 ; 96/60 ___grave___ + .byte $09 ; 97/61 _____a_____ + .byte $09 ; 98/62 _____b_____ + .byte $09 ; 99/63 _____c_____ + .byte $09 ; 100/64 _____d_____ + .byte $09 ; 101/65 _____e_____ + .byte $09 ; 102/66 _____f_____ + .byte $01 ; 103/67 _____g_____ + .byte $01 ; 104/68 _____h_____ + .byte $01 ; 105/69 _____i_____ + .byte $01 ; 106/6a _____j_____ + .byte $01 ; 107/6b _____k_____ + .byte $01 ; 108/6c _____l_____ + .byte $01 ; 109/6d _____m_____ + .byte $01 ; 110/6e _____n_____ + .byte $01 ; 111/6f _____o_____ + .byte $01 ; 112/70 _____p_____ + .byte $01 ; 113/71 _____q_____ + .byte $01 ; 114/72 _____r_____ + .byte $01 ; 115/73 _____s_____ + .byte $01 ; 116/74 _____t_____ + .byte $01 ; 117/75 _____u_____ + .byte $01 ; 118/76 _____v_____ + .byte $01 ; 119/77 _____w_____ + .byte $01 ; 120/78 _____x_____ + .byte $01 ; 121/79 _____y_____ + .byte $01 ; 122/7a _____z_____ + .byte $00 ; 123/7b _____{_____ + .byte $00 ; 124/7c _____|_____ + .byte $00 ; 125/7d _____}_____ + .byte $00 ; 126/7e _____~_____ + .byte $40 ; 127/7f ____DEL____ + +.endrepeat diff --git a/libsrc/creativision/cvline.s b/libsrc/creativision/cvline.s new file mode 100644 index 000000000..4e7d2563e --- /dev/null +++ b/libsrc/creativision/cvline.s @@ -0,0 +1,29 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; +; void cvlinexy (unsigned char x, unsigned char y, unsigned char length); +; void cvline (unsigned char length); +; + + .export _cvlinexy, _cvline + .import popa, _gotoxy, putchar, newline + .importzp tmp1 + + .include "creativision.inc" + +_cvlinexy: + pha ; Save the length + jsr popa ; Get y + jsr _gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cvline + +_cvline: + cmp #0 ; Is the length zero? + beq L9 ; Jump if done + sta tmp1 +L1: lda #CH_VLINE ; Vertical bar + jsr putchar ; Write, no cursor advance + jsr newline ; Advance cursor to next line + dec tmp1 + bne L1 +L9: rts diff --git a/libsrc/creativision/gotox.s b/libsrc/creativision/gotox.s new file mode 100644 index 000000000..6970e5d24 --- /dev/null +++ b/libsrc/creativision/gotox.s @@ -0,0 +1,19 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; void gotox (unsigned char x); +; + + .export _gotox + .import setcursor + + .include "creativision.inc" + +.proc _gotox + + sta CURSOR_X ; Set new position + tay + ldx CURSOR_Y + jmp setcursor ; Set the cursor to the new position + +.endproc diff --git a/libsrc/creativision/gotoxy.s b/libsrc/creativision/gotoxy.s new file mode 100644 index 000000000..6c0cf932f --- /dev/null +++ b/libsrc/creativision/gotoxy.s @@ -0,0 +1,22 @@ +; +; Ullrich von Bassewitz, 06.08.1998 +; +; void gotoxy (unsigned char x, unsigned char y); +; + + .export _gotoxy + .import setcursor + .import popa + + .include "creativision.inc" + +.proc _gotoxy + + sta CURSOR_Y ; Set Y + jsr popa ; Get X + sta CURSOR_X ; Set X + tay + ldx CURSOR_Y + jmp setcursor ; Set the cursor position + +.endproc diff --git a/libsrc/creativision/gotoy.s b/libsrc/creativision/gotoy.s new file mode 100644 index 000000000..484608d75 --- /dev/null +++ b/libsrc/creativision/gotoy.s @@ -0,0 +1,19 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; void gotoy (unsigned char y); +; + + .export _gotoy + .import setcursor + + .include "creativision.inc" + +.proc _gotoy + + sta CURSOR_Y ; Set new position + tax + ldy CURSOR_X + jmp setcursor ; Set the cursor to the new position + +.endproc diff --git a/libsrc/creativision/joy.s b/libsrc/creativision/joy.s new file mode 100644 index 000000000..f1c9b09f7 --- /dev/null +++ b/libsrc/creativision/joy.s @@ -0,0 +1,58 @@ +;* +;* Creativision Joystick Function +;* +;* unsigned char __fastcall__ joystate(unsigned char joy); +;* +;* JOY_1 -> Return Left Joystick direction +;* JOY_2 -> Return Right Joystick direction +;* JOY_3 -> Return Left Joystick buttons +;* JOY_4 -> Return Right Joystick buttons +;* +;* Will only work if interrupts are enabled. + + .export _joystate + .include "creativision.inc" + +_joystate: + cmp #1 ; Left Direction + bne l1 + + lda $11 + beq l5 + and #$f + lsr a + tax + inx + txa + rts + +l1: cmp #2 ; Right Direction + bne l2 + + lda $13 + beq l5 + and #$f + lsr a + tax + inx + txa + rts + +l2: cmp #3 ; Left Buttons + bne l3 + + lda $16 + beq l5 + and #$f + rts + +l3: cmp #4 + bne l4 + + lda $17 + beq l5 + and #$f + rts + +l4: lda #0 +l5: rts diff --git a/libsrc/creativision/libref.s b/libsrc/creativision/libref.s new file mode 100644 index 000000000..d947c1aa4 --- /dev/null +++ b/libsrc/creativision/libref.s @@ -0,0 +1,9 @@ +; +; Oliver Schmidt, 2013-05-31 +; + + .export joy_libref, tgi_libref + .import _exit + +joy_libref := _exit +tgi_libref := _exit diff --git a/libsrc/creativision/mainargs.s b/libsrc/creativision/mainargs.s new file mode 100644 index 000000000..7ed8d46f4 --- /dev/null +++ b/libsrc/creativision/mainargs.s @@ -0,0 +1,24 @@ +; +; 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 + + diff --git a/libsrc/creativision/psg.s b/libsrc/creativision/psg.s new file mode 100644 index 000000000..12b474339 --- /dev/null +++ b/libsrc/creativision/psg.s @@ -0,0 +1,68 @@ +; void __fastcall__ psg_outb( unsigned char b ); +; void __fastcall__ psg_delayms( unsigned char c); +; void __fastcall__ bios_playsound( void *b, unsigned char c); +; void psg_silence( void ); + + .export _psg_outb, _psg_silence, _psg_delay + .export _bios_playsound + .import popa + .include "creativision.inc" + +_psg_outb: + + ;* Let BIOS output the value + jmp $FE77 + +_psg_silence: + + jmp $FE54 + + +_psg_delay: + + tay +l1: + lda #200 +l2: + sbc #1 + bne l2 + + lda #200 +l3: + sbc #1 + bne l3 + + dey + bne l1 + + rts + + +;* Creativision Sound Player +;* +;* Based on BIOS sound player. +;* Pass a pointer to a set of note triples, terminated with a tempo byte +;* and the len (max 255) + +_bios_playsound: + + pha ; Save Length Byte + + sei + + lda #$D5 ; BIOS volume table low + sta $4 + lda #$FC ; BIOS volume table high + sta $5 + + jsr popa ; Get Sound table pointer low + sta $0 + jsr popa ; Get Sound table pointer high + sta $1 + + pla + tay ; Put length in Y + dey + php + jmp $fbed ; Let BIOS do it's thing + diff --git a/libsrc/creativision/setcursor.s b/libsrc/creativision/setcursor.s new file mode 100644 index 000000000..9918cbcb2 --- /dev/null +++ b/libsrc/creativision/setcursor.s @@ -0,0 +1,36 @@ +; +; Written by Groepaz/Hitmen +; Cleanup by Ullrich von Bassewitz +; +; Set the cursor position + + .export setcursor + + .include "creativision.inc" + +;----------------------------------------------------------------------------- + +.proc setcursor + + tya + clc + adc addrlo,x + sta SCREEN_PTR + + lda addrhi,x + adc #0 + sta SCREEN_PTR+1 + rts + +.endproc + +;----------------------------------------------------------------------------- +; Tables with screen addresses + +addrlo: .repeat SCREEN_ROWS,line + .byte <($1000+(line*SCREEN_COLS)) + .endrepeat + +addrhi: .repeat SCREEN_ROWS,line + .byte >($1000+(line*SCREEN_COLS)) + .endrepeat diff --git a/libsrc/creativision/sysuname.s b/libsrc/creativision/sysuname.s new file mode 100644 index 000000000..df1a81b67 --- /dev/null +++ b/libsrc/creativision/sysuname.s @@ -0,0 +1,39 @@ +; +; Ullrich von Bassewitz, 2003-08-12 +; +; unsigned char __fastcall__ _sysuname (struct utsname* buf); +; + + .export __sysuname, utsdata + + .import utscopy + + __sysuname = utscopy + +;-------------------------------------------------------------------------- +; Data. We define a fixed utsname struct here and just copy it. + +.rodata + +utsdata: + ; sysname + .asciiz "cc65" + + ; nodename + .asciiz "" + + ; release + .byte ((.VERSION >> 8) & $0F) + '0' + .byte '.' + .byte ((.VERSION >> 4) & $0F) + '0' + .byte $00 + + ; version + .byte (.VERSION & $0F) + '0' + .byte $00 + + ; machine + .asciiz "CREATIVISION" + + + diff --git a/libsrc/creativision/wherex.s b/libsrc/creativision/wherex.s new file mode 100644 index 000000000..f9df2d1a1 --- /dev/null +++ b/libsrc/creativision/wherex.s @@ -0,0 +1,19 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; unsigned char wherex (void); +; + + .export _wherex + + .include "creativision.inc" + +.proc _wherex + + lda CURSOR_X + ldx #$00 + rts + +.endproc + + diff --git a/libsrc/creativision/wherey.s b/libsrc/creativision/wherey.s new file mode 100644 index 000000000..6d7b056f5 --- /dev/null +++ b/libsrc/creativision/wherey.s @@ -0,0 +1,19 @@ +; +; Ullrich von Bassewitz, 2003-05-02 +; +; unsigned char wherey (void); +; + + .export _wherey + + .include "creativision.inc" + +.proc _wherey + + lda CURSOR_Y + ldx #$00 + rts + +.endproc + + From 54e09fdd0369fe4388956ca7ed65528af1675bd7 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Mon, 25 Nov 2013 22:52:04 +0100 Subject: [PATCH 02/11] Added basic frame for new target 'creativision'. Kym Greenshields has expressed interest in contributing and maintaining support for the VTech CreatiVision system. this resembles commit 8e6b8dd0afed52c1963ea29c4921157693463cbe from oliver --- cfg/creativision.cfg | 35 +++++++++++++ libsrc/Makefile | 1 + libsrc/creativision/crt0.s | 102 +++++++++++++++++++++++++++++++++++++ src/ca65/main.c | 38 +++++++++----- src/cc65/main.c | 38 +++++++++----- src/common/target.c | 16 +++--- src/common/target.h | 15 +++--- 7 files changed, 203 insertions(+), 42 deletions(-) create mode 100644 cfg/creativision.cfg create mode 100644 libsrc/creativision/crt0.s diff --git a/cfg/creativision.cfg b/cfg/creativision.cfg new file mode 100644 index 000000000..9122ccd42 --- /dev/null +++ b/cfg/creativision.cfg @@ -0,0 +1,35 @@ +SYMBOLS { + __STACKSIZE__: type = weak, value = $0180; +} +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; +} +SEGMENTS { + ZEROPAGE: load = ZP, type = zp; + ZP: load = ZP, type = zp, optional = yes; + VECTORS: load = ROM, run = RAM, type = rw, define = yes; + DATA: load = ROM, run = RAM, type = rw, define = yes, start = $0204; + BSS: load = RAM, type = bss, define = yes; + CODE: load = ROM, type = ro; + INIT: load = ROM, type = ro; + RODATA: load = ROM, type = ro; + AUDIO: load = ROM, type = ro, optional = yes, start = $BF00; + SETUP: load = ROM, type = ro, start = $BFE8; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = INIT; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/libsrc/Makefile b/libsrc/Makefile index a4101aecd..364b266c8 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -20,6 +20,7 @@ TARGETS = apple2 \ atarixl \ atari5200 \ atmos \ + creativision \ $(CBMS) \ $(GEOS) \ gamate \ diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s new file mode 100644 index 000000000..ccae38e81 --- /dev/null +++ b/libsrc/creativision/crt0.s @@ -0,0 +1,102 @@ +; +; Startup code for cc65 (CreatiVision version) +; + + .export _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup + .import zerobss, copydata + .import initlib, donelib, callmain + .import __VECTORS_LOAD__, __VECTORS_RUN__, __VECTORS_SIZE__ + .import __ZP_LAST__, __STACKSIZE__, __RAM_START__ + + .include "zeropage.inc" + +; ------------------------------------------------------------------------ + +entry: + ; Init the CPU + sei + cld + + ; Copy the IRQ vectors + ldx #<__VECTORS_SIZE__ - 1 +: lda __VECTORS_LOAD__,x + sta __VECTORS_RUN__,x + dex + bpl :- + + ; Setup the CPU stack ptr + ldx #<__RAM_START__ - 1 + txs + + ; Start interrupts + cli + + ; Clear the BSS data + jsr zerobss + + ; Copy data from ROM to RAM + jsr copydata + + ; Setup the argument stack ptr + lda #<(__ZP_LAST__ + __STACKSIZE__) + ldx #>(__ZP_LAST__ + __STACKSIZE__) + sta sp + stx sp+1 + + ; Call module constructors + jsr initlib + + ; Call main() + jsr callmain + + ; Call module destructors. This is also the _exit entry. +_exit: jsr donelib + + ; TODO: Replace with some sort of reset +loop: jmp loop + +; ------------------------------------------------------------------------ +; Define the IRQ vectors. + +.segment "VECTORS" + +irq1: jmp $FF3F +irq2: jmp $FF52 + +; ------------------------------------------------------------------------ +; Define CART setup values for BIOS. + +.segment "SETUP" + + ; BIOS Jump Start + ; This is where the entry point of the program needs to be + .addr entry + .addr irq2 + + .res 4 + + ; VDP Setup + ; This sets to Graphics Mode 1 + .byte $00 ; Register 0 + .byte $C0 ; Register 1 16K RAM, Active Display, Mode 1 + .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 + .byte $10 ; Register 5 Sprite Attribute at $0800 - $087F + .byte $01 ; Register 6 Sprite Pattern + .byte $F1 ; Register 7 Text colour Foreground / background + + .res 4 + + ; BIOS Vector after NMI or RESET + ; Keeping with retail cartridges, we jump back to BIOS ROM and have it + ; setup zeropage etc, and show the Creativision logo and copyright. + .addr $F808 + + ; BIOS Short Interrupt Handler + ; Vectored from BIOS ROM:FE2C. This should contain a pointer to the user's + ; BIOS interrupt handler. + .addr irq1 + +; ------------------------------------------------------------------------ diff --git a/src/ca65/main.c b/src/ca65/main.c index 0016c46f3..b25d5ad9f 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -251,10 +251,6 @@ static void SetSys (const char* Sys) CBMSystem ("__PET__"); break; - case TGT_BBC: - NewSymbol ("__BBC__", 1); - break; - case TGT_APPLE2: NewSymbol ("__APPLE2__", 1); break; @@ -274,31 +270,41 @@ static void SetSys (const char* Sys) NewSymbol ("__GEOS_CBM__", 1); break; + case TGT_ATMOS: + NewSymbol ("__ATMOS__", 1); + break; + + case TGT_BBC: + NewSymbol ("__BBC__", 1); + break; + + case TGT_CREATIVISION: + NewSymbol ("__CREATIVISION__", 1); + break; + case TGT_GEOS_APPLE: NewSymbol ("__GEOS__", 1); NewSymbol ("__GEOS_APPLE__", 1); break; + case TGT_GEOS_CBM: + /* Do not handle as a CBM system */ + NewSymbol ("__GEOS__", 1); + NewSymbol ("__GEOS_CBM__", 1); + break; + case TGT_LUNIX: NewSymbol ("__LUNIX__", 1); break; - case TGT_ATMOS: - NewSymbol ("__ATMOS__", 1); + case TGT_LYNX: + NewSymbol ("__LYNX__", 1); break; case TGT_NES: NewSymbol ("__NES__", 1); break; - case TGT_SUPERVISION: - NewSymbol ("__SUPERVISION__", 1); - break; - - case TGT_LYNX: - NewSymbol ("__LYNX__", 1); - break; - case TGT_SIM6502: NewSymbol ("__SIM6502__", 1); break; @@ -315,6 +321,10 @@ static void SetSys (const char* Sys) NewSymbol ("__PCE__", 1); break; + case TGT_SUPERVISION: + NewSymbol ("__SUPERVISION__", 1); + break; + default: AbEnd ("Invalid target name: `%s'", Sys); diff --git a/src/cc65/main.c b/src/cc65/main.c index abe2af56e..c4a5c3788 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -207,10 +207,6 @@ static void SetSys (const char* Sys) cbmsys ("__PET__"); break; - case TGT_BBC: - DefineNumericMacro ("__BBC__", 1); - break; - case TGT_APPLE2: DefineNumericMacro ("__APPLE2__", 1); break; @@ -230,31 +226,41 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__GEOS_CBM__", 1); break; + case TGT_ATMOS: + DefineNumericMacro ("__ATMOS__", 1); + break; + + case TGT_BBC: + DefineNumericMacro ("__BBC__", 1); + break; + + case TGT_CREATIVISION: + DefineNumericMacro ("__CREATIVISION__", 1); + break; + case TGT_GEOS_APPLE: DefineNumericMacro ("__GEOS__", 1); DefineNumericMacro ("__GEOS_APPLE__", 1); break; + case TGT_GEOS_CBM: + /* Do not handle as a CBM system */ + DefineNumericMacro ("__GEOS__", 1); + DefineNumericMacro ("__GEOS_CBM__", 1); + break; + case TGT_LUNIX: DefineNumericMacro ("__LUNIX__", 1); break; - case TGT_ATMOS: - DefineNumericMacro ("__ATMOS__", 1); + case TGT_LYNX: + DefineNumericMacro ("__LYNX__", 1); break; case TGT_NES: DefineNumericMacro ("__NES__", 1); break; - case TGT_SUPERVISION: - DefineNumericMacro ("__SUPERVISION__", 1); - break; - - case TGT_LYNX: - DefineNumericMacro ("__LYNX__", 1); - break; - case TGT_SIM6502: DefineNumericMacro ("__SIM6502__", 1); break; @@ -271,6 +277,10 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__PCE__", 1); break; + case TGT_SUPERVISION: + DefineNumericMacro ("__SUPERVISION__", 1); + break; + default: AbEnd ("Unknown target system type %d", Target); } diff --git a/src/common/target.c b/src/common/target.c index e89010123..cc5d41206 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -134,7 +134,7 @@ static const unsigned char CTPET[256] = { /* One entry in the target map */ typedef struct TargetEntry TargetEntry; struct TargetEntry { - char Name[12]; /* Target name */ + char Name[13]; /* Target name */ target_t Id; /* Target id */ }; @@ -154,6 +154,7 @@ static const TargetEntry TargetMap[] = { { "c64", TGT_C64 }, { "cbm510", TGT_CBM510 }, { "cbm610", TGT_CBM610 }, + { "creativision", TGT_CREATIVISION}, { "gamate", TGT_GAMATE }, { "geos", TGT_GEOS_CBM }, { "geos-apple", TGT_GEOS_APPLE }, @@ -192,20 +193,21 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "cbm610", CPU_6502, BINFMT_BINARY, CTPET }, { "osic1p", CPU_6502, BINFMT_BINARY, CTOSI }, { "pet", CPU_6502, BINFMT_BINARY, CTPET }, - { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2enh", CPU_65C02, BINFMT_BINARY, CTNone }, - { "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone }, - { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, - { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, - { "nes", CPU_6502, BINFMT_BINARY, CTNone }, - { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, + { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, + { "creativision", CPU_6502, BINFMT_BINARY, CTNone }, + { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, + { "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone }, + { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "lynx", CPU_65C02, BINFMT_BINARY, CTNone }, + { "nes", CPU_6502, BINFMT_BINARY, CTNone }, { "sim6502", CPU_6502, BINFMT_BINARY, CTNone }, { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, + { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, }; /* Target system */ diff --git a/src/common/target.h b/src/common/target.h index 6366b725f..c266a4408 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -66,27 +66,28 @@ typedef enum { TGT_CBM610, TGT_OSIC1P, TGT_PET, - TGT_BBC, TGT_APPLE2, TGT_APPLE2ENH, - TGT_GEOS_CBM, - TGT_GEOS_APPLE, - TGT_LUNIX, TGT_ATMOS, - TGT_NES, - TGT_SUPERVISION, + TGT_BBC, + TGT_CREATIVISION, + TGT_GEOS_APPLE, + TGT_GEOS_CBM, + TGT_LUNIX, TGT_LYNX, + TGT_NES, TGT_SIM6502, TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, + TGT_SUPERVISION, TGT_COUNT /* Number of target systems */ } target_t; /* Collection of target properties */ typedef struct TargetProperties TargetProperties; struct TargetProperties { - const char Name[12]; /* Name of the target */ + const char Name[13]; /* Name of the target */ cpu_t DefaultCPU; /* Default CPU for this target */ unsigned char BinFmt; /* Default binary format for this target */ const unsigned char* CharMap; /* Character translation table */ From 0dc85268c4c4c4651899b6211984b07f8b25723c Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sun, 28 Feb 2016 19:11:04 +0100 Subject: [PATCH 03/11] fix merge fxxxup --- src/ca65/main.c | 6 ------ src/cc65/main.c | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index b25d5ad9f..49e7a1fb5 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -287,12 +287,6 @@ static void SetSys (const char* Sys) NewSymbol ("__GEOS_APPLE__", 1); break; - case TGT_GEOS_CBM: - /* Do not handle as a CBM system */ - NewSymbol ("__GEOS__", 1); - NewSymbol ("__GEOS_CBM__", 1); - break; - case TGT_LUNIX: NewSymbol ("__LUNIX__", 1); break; diff --git a/src/cc65/main.c b/src/cc65/main.c index c4a5c3788..d8b312fab 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -243,12 +243,6 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__GEOS_APPLE__", 1); break; - case TGT_GEOS_CBM: - /* Do not handle as a CBM system */ - DefineNumericMacro ("__GEOS__", 1); - DefineNumericMacro ("__GEOS_CBM__", 1); - break; - case TGT_LUNIX: DefineNumericMacro ("__LUNIX__", 1); break; From a08f90522459634aace3f5db9f81045bce204d38 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Wed, 1 Feb 2017 19:46:04 +0100 Subject: [PATCH 04/11] Cleanups for Creativision. --- cfg/creativision.cfg | 1 + libsrc/creativision/_scrsize.s | 10 +-- libsrc/creativision/boxchars.inc | 112 +++++++++++++++---------------- libsrc/creativision/cclear.s | 43 ++++++------ libsrc/creativision/cgetc.s | 25 +++---- libsrc/creativision/chline.s | 2 +- libsrc/creativision/clrscr.s | 66 +++++++++--------- libsrc/creativision/color.s | 14 ++-- libsrc/creativision/cputc.s | 54 +++++++-------- libsrc/creativision/gotox.s | 2 +- libsrc/creativision/gotoxy.s | 6 +- libsrc/creativision/joy.s | 28 ++++---- libsrc/creativision/libref.s | 4 +- libsrc/creativision/mainargs.s | 2 - libsrc/creativision/psg.s | 91 ++++++++++++------------- libsrc/creativision/sysuname.s | 3 - libsrc/creativision/wherex.s | 3 - libsrc/creativision/wherey.s | 3 - src/ca65/main.c | 28 ++++---- src/cc65/main.c | 28 ++++---- src/common/target.c | 70 ++++++++++--------- src/common/target.h | 10 +-- 22 files changed, 291 insertions(+), 314 deletions(-) diff --git a/cfg/creativision.cfg b/cfg/creativision.cfg index 9122ccd42..06e39b36f 100644 --- a/cfg/creativision.cfg +++ b/cfg/creativision.cfg @@ -12,6 +12,7 @@ SEGMENTS { VECTORS: load = ROM, run = RAM, type = rw, define = yes; DATA: load = ROM, run = RAM, type = rw, define = yes, start = $0204; BSS: load = RAM, type = bss, define = yes; + ONCE: load = ROM, type = ro, optional = yes; CODE: load = ROM, type = ro; INIT: load = ROM, type = ro; RODATA: load = ROM, type = ro; diff --git a/libsrc/creativision/_scrsize.s b/libsrc/creativision/_scrsize.s index fdcc7fc60..9e4ce53c7 100644 --- a/libsrc/creativision/_scrsize.s +++ b/libsrc/creativision/_scrsize.s @@ -2,14 +2,14 @@ ;** _scrsize.s ;* - .export screensize + .export screensize - .include "creativision.inc" + .include "creativision.inc" .proc screensize - ldx #SCREEN_COLS - ldy #SCREEN_ROWS - rts + ldx #SCREEN_COLS + ldy #SCREEN_ROWS + rts .endproc diff --git a/libsrc/creativision/boxchars.inc b/libsrc/creativision/boxchars.inc index 0916d49ce..45484a5d2 100644 --- a/libsrc/creativision/boxchars.inc +++ b/libsrc/creativision/boxchars.inc @@ -1,62 +1,62 @@ ; Boxchars boxchars: - ; Vertical Line - .byte $18 - .byte $18 - .byte $18 - .byte $18 - .byte $18 - .byte $18 - .byte $18 - .byte $18 + ; Vertical Line + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + .byte $18 - ; Horizontal Line - .byte 0 - .byte 0 - .byte 0 - .byte $ff - .byte 0 - .byte 0 - .byte 0 - .byte 0 - - ; Top Left - .byte 0 - .byte 0 - .byte 0 - .byte $1f - .byte $18 - .byte $18 - .byte $18 - .byte $18 - - ; Top Right - .byte 0 - .byte 0 - .byte 0 - .byte $F8 - .byte $18 - .byte $18 - .byte $18 - .byte $18 + ; Horizontal Line + .byte $00 + .byte $00 + .byte $00 + .byte $FF + .byte $00 + .byte $00 + .byte $00 + .byte $00 - ; Bottom Left - .byte $18 - .byte $18 - .byte $18 - .byte $1F - .byte 0 - .byte 0 - .byte 0 - .byte 0 + ; Top Left + .byte $00 + .byte $00 + .byte $00 + .byte $1F + .byte $18 + .byte $18 + .byte $18 + .byte $18 - ; Bottom Right - .byte $18 - .byte $18 - .byte $18 - .byte $F8 - .byte 0 - .byte 0 - .byte 0 - .byte 0 + ; Top Right + .byte $00 + .byte $00 + .byte $00 + .byte $F8 + .byte $18 + .byte $18 + .byte $18 + .byte $18 + + ; Bottom Left + .byte $18 + .byte $18 + .byte $18 + .byte $1F + .byte $00 + .byte $00 + .byte $00 + .byte $00 + + ; Bottom Right + .byte $18 + .byte $18 + .byte $18 + .byte $F8 + .byte $00 + .byte $00 + .byte $00 + .byte $00 diff --git a/libsrc/creativision/cclear.s b/libsrc/creativision/cclear.s index 507c072bd..953ec8ce8 100644 --- a/libsrc/creativision/cclear.s +++ b/libsrc/creativision/cclear.s @@ -3,27 +3,24 @@ ;* void cclear (unsigned char length); ;* - .export _cclearxy, _cclear - .import popa, _gotoxy, cputdirect - .importzp tmp1 - -_cclearxy: - pha ; Save length - jsr popa ; get Y - jsr _gotoxy - pla - -_cclear: - cmp #0 ; Zero length? - beq L2 - sta tmp1 - -L1: - lda #$20 ; Space - jsr cputdirect - dec tmp1 - bne L1 - -L2: rts + .export _cclearxy, _cclear + .import popa, _gotoxy, cputdirect + .importzp tmp1 - +_cclearxy: + pha ; Save length + jsr popa ; get Y + jsr _gotoxy + pla + +_cclear: + cmp #0 ; Zero length? + beq L2 + sta tmp1 + +L1: lda #$20 ; Space + jsr cputdirect + dec tmp1 + bne L1 + +L2: rts diff --git a/libsrc/creativision/cgetc.s b/libsrc/creativision/cgetc.s index f1e89942a..12831b4b9 100644 --- a/libsrc/creativision/cgetc.s +++ b/libsrc/creativision/cgetc.s @@ -1,17 +1,14 @@ ;* cgetc - .export _cgetc - .include "creativision.inc" - + .export _cgetc + .include "creativision.inc" + _cgetc: - lda #$80 - -L1: - bit ZP_KEYBOARD - bpl L1 - - lda ZP_KEYBOARD - and #$7f - rts - - + lda #$80 + +L1: bit ZP_KEYBOARD + bpl L1 + + lda ZP_KEYBOARD + and #$7F + rts diff --git a/libsrc/creativision/chline.s b/libsrc/creativision/chline.s index c206180e0..bef36e1fe 100644 --- a/libsrc/creativision/chline.s +++ b/libsrc/creativision/chline.s @@ -6,7 +6,7 @@ .importzp tmp1 .include "creativision.inc" - + _chlinexy: pha ; Save the length jsr popa ; Get y diff --git a/libsrc/creativision/clrscr.s b/libsrc/creativision/clrscr.s index ef800a9bd..9e7238345 100644 --- a/libsrc/creativision/clrscr.s +++ b/libsrc/creativision/clrscr.s @@ -4,38 +4,38 @@ ;* NB: All screen functions assume Graphics Mode 1 in a default configuration. ;* Therefore, this is hard coded to use $1000-$12FF as screen VRAM. - .export _clrscr - .include "creativision.inc" - + .export _clrscr + .include "creativision.inc" + _clrscr: - sei ; Disable interrupts. Default INT handler reads VDP_STATUS - ; and would lose any setup done here. - - lda #$00 ; VRAM offset low - sta VDP_CONTROL_W - - lda #$50 ; VRAM offset high ($10 OR $40) - sta VDP_CONTROL_W - - lda #$C0 ; Space from ROM setup - - ldx #0 - ldy #3 - -L1: sta VDP_DATA_W - inx - bne L1 - dey - bne L1 - - cli ; Let interrupts go again - - lda #0 - sta CURSOR_X - sta CURSOR_Y - sta SCREEN_PTR - - rts + sei ; Disable interrupts. Default INT handler reads VDP_STATUS + ; and would lose any setup done here. + + lda #$00 ; VRAM offset low + sta VDP_CONTROL_W + + lda #$50 ; VRAM offset high ($10 OR $40) + sta VDP_CONTROL_W + + lda #$C0 ; Space from ROM setup + + ldx #0 + ldy #3 + +L1: sta VDP_DATA_W + inx + bne L1 + dey + bne L1 + + cli ; Let interrupts go again + + lda #0 + sta CURSOR_X + sta CURSOR_Y + sta SCREEN_PTR + + rts diff --git a/libsrc/creativision/color.s b/libsrc/creativision/color.s index b6fd360b4..8e86719d2 100644 --- a/libsrc/creativision/color.s +++ b/libsrc/creativision/color.s @@ -4,10 +4,10 @@ ;* unsigned char __fastcall__ bordercolor (unsigned char color); ;* - .export _textcolor, _bgcolor, _bordercolor - .import return0 - .include "creativision.inc" - -_bordercolor = return0; -_textcolor = return0; -_bgcolor = return0; + .export _textcolor, _bgcolor, _bordercolor + .import return0 + .include "creativision.inc" + +_bordercolor = return0; +_textcolor = return0; +_bgcolor = return0; diff --git a/libsrc/creativision/cputc.s b/libsrc/creativision/cputc.s index 902caf277..208009ebd 100644 --- a/libsrc/creativision/cputc.s +++ b/libsrc/creativision/cputc.s @@ -29,13 +29,13 @@ _cputcxy: ; Plot a character - also used as internal function -_cputc: cmp #$0d ; CR? +_cputc: cmp #$0D ; CR? bne L1 lda #0 sta CURSOR_X beq plot ; Recalculate pointers -L1: cmp #$0a ; LF? +L1: cmp #$0A ; LF? beq newline ; Recalculate pointers ; Printable char of some sort @@ -82,19 +82,19 @@ IS_UPPER: pha lda SCREEN_PTR sei - sta VDP_CONTROL_W + sta VDP_CONTROL_W lda SCREEN_PTR+1 - ora #$40 - sta VDP_CONTROL_W + ora #$40 + sta VDP_CONTROL_W pla clc - adc #160 - sta VDP_DATA_W + adc #160 + sta VDP_DATA_W cli BAD_CHAR: jmp plot - + ;----------------------------------------------------------------------------- ; Initialize the conio subsystem. Code goes into the INIT segment, which may ; be reused after startup. @@ -102,24 +102,24 @@ BAD_CHAR: .segment "INIT" initconio: - lda #$0 - sta SCREEN_PTR - lda #$10 - sta SCREEN_PTR+1 + lda #$0 + sta SCREEN_PTR + lda #$10 + sta SCREEN_PTR+1 - ; Copy box characters to slot - sei - lda #08 - sta VDP_CONTROL_W - lda #$46 - sta VDP_CONTROL_W - ldx #0 -LL: - lda boxchars,x - sta VDP_DATA_W - inx - cpx #48 - bne LL + ; Copy box characters to slot + sei + lda #08 + sta VDP_CONTROL_W + lda #$46 + sta VDP_CONTROL_W + ldx #0 - cli - jmp plot +LL: lda boxchars,x + sta VDP_DATA_W + inx + cpx #48 + bne LL + + cli + jmp plot diff --git a/libsrc/creativision/gotox.s b/libsrc/creativision/gotox.s index 6970e5d24..f65e923b5 100644 --- a/libsrc/creativision/gotox.s +++ b/libsrc/creativision/gotox.s @@ -11,7 +11,7 @@ .proc _gotox - sta CURSOR_X ; Set new position + sta CURSOR_X ; Set new position tay ldx CURSOR_Y jmp setcursor ; Set the cursor to the new position diff --git a/libsrc/creativision/gotoxy.s b/libsrc/creativision/gotoxy.s index 6c0cf932f..12ce0abea 100644 --- a/libsrc/creativision/gotoxy.s +++ b/libsrc/creativision/gotoxy.s @@ -12,9 +12,9 @@ .proc _gotoxy - sta CURSOR_Y ; Set Y - jsr popa ; Get X - sta CURSOR_X ; Set X + sta CURSOR_Y ; Set Y + jsr popa ; Get X + sta CURSOR_X ; Set X tay ldx CURSOR_Y jmp setcursor ; Set the cursor position diff --git a/libsrc/creativision/joy.s b/libsrc/creativision/joy.s index f1c9b09f7..eb0bc6594 100644 --- a/libsrc/creativision/joy.s +++ b/libsrc/creativision/joy.s @@ -1,6 +1,6 @@ ;* ;* Creativision Joystick Function -;* +;* ;* unsigned char __fastcall__ joystate(unsigned char joy); ;* ;* JOY_1 -> Return Left Joystick direction @@ -12,47 +12,47 @@ .export _joystate .include "creativision.inc" - + _joystate: cmp #1 ; Left Direction bne l1 - + lda $11 beq l5 - and #$f + and #$0F lsr a tax inx txa rts - + l1: cmp #2 ; Right Direction bne l2 - + lda $13 beq l5 - and #$f + and #$0F lsr a tax inx txa rts - + l2: cmp #3 ; Left Buttons bne l3 - + lda $16 beq l5 - and #$f + and #$0F rts - + l3: cmp #4 bne l4 - + lda $17 beq l5 - and #$f + and #$0F rts - + l4: lda #0 l5: rts diff --git a/libsrc/creativision/libref.s b/libsrc/creativision/libref.s index d947c1aa4..b642da80a 100644 --- a/libsrc/creativision/libref.s +++ b/libsrc/creativision/libref.s @@ -5,5 +5,5 @@ .export joy_libref, tgi_libref .import _exit -joy_libref := _exit -tgi_libref := _exit +joy_libref := _exit +tgi_libref := _exit diff --git a/libsrc/creativision/mainargs.s b/libsrc/creativision/mainargs.s index 7ed8d46f4..cda76d8d0 100644 --- a/libsrc/creativision/mainargs.s +++ b/libsrc/creativision/mainargs.s @@ -20,5 +20,3 @@ rts .endproc - - diff --git a/libsrc/creativision/psg.s b/libsrc/creativision/psg.s index 12b474339..a32e87f02 100644 --- a/libsrc/creativision/psg.s +++ b/libsrc/creativision/psg.s @@ -3,40 +3,37 @@ ; void __fastcall__ bios_playsound( void *b, unsigned char c); ; void psg_silence( void ); - .export _psg_outb, _psg_silence, _psg_delay - .export _bios_playsound - .import popa - .include "creativision.inc" - + .export _psg_outb, _psg_silence, _psg_delay + .export _bios_playsound + .import popa + .include "creativision.inc" + _psg_outb: - ;* Let BIOS output the value - jmp $FE77 - + ;* Let BIOS output the value + jmp $FE77 + _psg_silence: - jmp $FE54 - - + jmp $FE54 + + _psg_delay: - tay -l1: - lda #200 -l2: - sbc #1 - bne l2 - - lda #200 -l3: - sbc #1 - bne l3 - - dey - bne l1 - - rts - + tay +l1: lda #200 +l2: sbc #1 + bne l2 + + lda #200 +l3: sbc #1 + bne l3 + + dey + bne l1 + + rts + ;* Creativision Sound Player ;* @@ -46,23 +43,21 @@ l3: _bios_playsound: - pha ; Save Length Byte - - sei - - lda #$D5 ; BIOS volume table low - sta $4 - lda #$FC ; BIOS volume table high - sta $5 - - jsr popa ; Get Sound table pointer low - sta $0 - jsr popa ; Get Sound table pointer high - sta $1 - - pla - tay ; Put length in Y - dey - php - jmp $fbed ; Let BIOS do it's thing - + pha ; Save Length Byte + sei + + lda #$D5 ; BIOS volume table low + sta $4 + lda #$FC ; BIOS volume table high + sta $5 + + jsr popa ; Get Sound table pointer low + sta $0 + jsr popa ; Get Sound table pointer high + sta $1 + + pla + tay ; Put length in Y + dey + php + jmp $FBED ; Let BIOS do it's thing diff --git a/libsrc/creativision/sysuname.s b/libsrc/creativision/sysuname.s index df1a81b67..725cb2a62 100644 --- a/libsrc/creativision/sysuname.s +++ b/libsrc/creativision/sysuname.s @@ -34,6 +34,3 @@ utsdata: ; machine .asciiz "CREATIVISION" - - - diff --git a/libsrc/creativision/wherex.s b/libsrc/creativision/wherex.s index f9df2d1a1..a2e6fdfc5 100644 --- a/libsrc/creativision/wherex.s +++ b/libsrc/creativision/wherex.s @@ -5,7 +5,6 @@ ; .export _wherex - .include "creativision.inc" .proc _wherex @@ -15,5 +14,3 @@ rts .endproc - - diff --git a/libsrc/creativision/wherey.s b/libsrc/creativision/wherey.s index 6d7b056f5..fa50177c4 100644 --- a/libsrc/creativision/wherey.s +++ b/libsrc/creativision/wherey.s @@ -5,7 +5,6 @@ ; .export _wherey - .include "creativision.inc" .proc _wherey @@ -15,5 +14,3 @@ rts .endproc - - diff --git a/src/ca65/main.c b/src/ca65/main.c index 1da0ff36d..a83cab5b6 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -259,6 +259,10 @@ static void SetSys (const char* Sys) CBMSystem ("__PET__"); break; + case TGT_BBC: + NewSymbol ("__BBC__", 1); + break; + case TGT_APPLE2: NewSymbol ("__APPLE2__", 1); break; @@ -278,14 +282,6 @@ static void SetSys (const char* Sys) NewSymbol ("__GEOS_CBM__", 1); break; - case TGT_ATMOS: - NewSymbol ("__ATMOS__", 1); - break; - - case TGT_BBC: - NewSymbol ("__BBC__", 1); - break; - case TGT_CREATIVISION: NewSymbol ("__CREATIVISION__", 1); break; @@ -299,14 +295,22 @@ static void SetSys (const char* Sys) NewSymbol ("__LUNIX__", 1); break; - case TGT_LYNX: - NewSymbol ("__LYNX__", 1); + case TGT_ATMOS: + NewSymbol ("__ATMOS__", 1); break; case TGT_NES: NewSymbol ("__NES__", 1); break; + case TGT_SUPERVISION: + NewSymbol ("__SUPERVISION__", 1); + break; + + case TGT_LYNX: + NewSymbol ("__LYNX__", 1); + break; + case TGT_SIM6502: NewSymbol ("__SIM6502__", 1); break; @@ -323,10 +327,6 @@ static void SetSys (const char* Sys) NewSymbol ("__PCE__", 1); break; - case TGT_SUPERVISION: - NewSymbol ("__SUPERVISION__", 1); - break; - default: AbEnd ("Invalid target name: `%s'", Sys); diff --git a/src/cc65/main.c b/src/cc65/main.c index c273d8160..780c52b57 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -211,6 +211,10 @@ static void SetSys (const char* Sys) cbmsys ("__PET__"); break; + case TGT_BBC: + DefineNumericMacro ("__BBC__", 1); + break; + case TGT_APPLE2: DefineNumericMacro ("__APPLE2__", 1); break; @@ -230,14 +234,6 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__GEOS_CBM__", 1); break; - case TGT_ATMOS: - DefineNumericMacro ("__ATMOS__", 1); - break; - - case TGT_BBC: - DefineNumericMacro ("__BBC__", 1); - break; - case TGT_CREATIVISION: DefineNumericMacro ("__CREATIVISION__", 1); break; @@ -251,14 +247,22 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__LUNIX__", 1); break; - case TGT_LYNX: - DefineNumericMacro ("__LYNX__", 1); + case TGT_ATMOS: + DefineNumericMacro ("__ATMOS__", 1); break; case TGT_NES: DefineNumericMacro ("__NES__", 1); break; + case TGT_SUPERVISION: + DefineNumericMacro ("__SUPERVISION__", 1); + break; + + case TGT_LYNX: + DefineNumericMacro ("__LYNX__", 1); + break; + case TGT_SIM6502: DefineNumericMacro ("__SIM6502__", 1); break; @@ -275,10 +279,6 @@ static void SetSys (const char* Sys) DefineNumericMacro ("__PCE__", 1); break; - case TGT_SUPERVISION: - DefineNumericMacro ("__SUPERVISION__", 1); - break; - default: AbEnd ("Unknown target system type %d", Target); } diff --git a/src/common/target.c b/src/common/target.c index bf87b17e0..84559b0e7 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -142,38 +142,38 @@ struct TargetEntry { ** Allows multiple entries for one target id (target name aliases). */ static const TargetEntry TargetMap[] = { - { "apple2", TGT_APPLE2 }, - { "apple2enh", TGT_APPLE2ENH }, - { "atari", TGT_ATARI }, - { "atari2600", TGT_ATARI2600 }, - { "atari5200", TGT_ATARI5200 }, - { "atarixl", TGT_ATARIXL }, - { "atmos", TGT_ATMOS }, - { "bbc", TGT_BBC }, - { "c128", TGT_C128 }, - { "c16", TGT_C16 }, - { "c64", TGT_C64 }, - { "c65", TGT_C65 }, - { "cbm510", TGT_CBM510 }, - { "cbm610", TGT_CBM610 }, - { "creativision", TGT_CREATIVISION}, - { "gamate", TGT_GAMATE }, - { "geos", TGT_GEOS_CBM }, - { "geos-apple", TGT_GEOS_APPLE }, - { "geos-cbm", TGT_GEOS_CBM }, - { "lunix", TGT_LUNIX }, - { "lynx", TGT_LYNX }, - { "module", TGT_MODULE }, - { "nes", TGT_NES }, - { "none", TGT_NONE }, - { "osic1p", TGT_OSIC1P }, - { "pce", TGT_PCENGINE }, - { "pet", TGT_PET }, - { "plus4", TGT_PLUS4 }, - { "sim6502", TGT_SIM6502 }, - { "sim65c02", TGT_SIM65C02 }, - { "supervision", TGT_SUPERVISION }, - { "vic20", TGT_VIC20 }, + { "apple2", TGT_APPLE2 }, + { "apple2enh", TGT_APPLE2ENH }, + { "atari", TGT_ATARI }, + { "atari2600", TGT_ATARI2600 }, + { "atari5200", TGT_ATARI5200 }, + { "atarixl", TGT_ATARIXL }, + { "atmos", TGT_ATMOS }, + { "bbc", TGT_BBC }, + { "c128", TGT_C128 }, + { "c16", TGT_C16 }, + { "c64", TGT_C64 }, + { "c65", TGT_C65 }, + { "cbm510", TGT_CBM510 }, + { "cbm610", TGT_CBM610 }, + { "creativision", TGT_CREATIVISION }, + { "gamate", TGT_GAMATE }, + { "geos", TGT_GEOS_CBM }, + { "geos-apple", TGT_GEOS_APPLE }, + { "geos-cbm", TGT_GEOS_CBM }, + { "lunix", TGT_LUNIX }, + { "lynx", TGT_LYNX }, + { "module", TGT_MODULE }, + { "nes", TGT_NES }, + { "none", TGT_NONE }, + { "osic1p", TGT_OSIC1P }, + { "pce", TGT_PCENGINE }, + { "pet", TGT_PET }, + { "plus4", TGT_PLUS4 }, + { "sim6502", TGT_SIM6502 }, + { "sim65c02", TGT_SIM65C02 }, + { "supervision", TGT_SUPERVISION }, + { "vic20", TGT_VIC20 }, }; #define MAP_ENTRY_COUNT (sizeof (TargetMap) / sizeof (TargetMap[0])) @@ -195,13 +195,12 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "cbm610", CPU_6502, BINFMT_BINARY, CTPET }, { "osic1p", CPU_6502, BINFMT_BINARY, CTOSI }, { "pet", CPU_6502, BINFMT_BINARY, CTPET }, + { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2", CPU_6502, BINFMT_BINARY, CTNone }, { "apple2enh", CPU_65C02, BINFMT_BINARY, CTNone }, - { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, - { "bbc", CPU_6502, BINFMT_BINARY, CTNone }, + { "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone }, { "creativision", CPU_6502, BINFMT_BINARY, CTNone }, { "geos-apple", CPU_65C02, BINFMT_BINARY, CTNone }, - { "geos-cbm", CPU_6502, BINFMT_BINARY, CTNone }, { "lunix", CPU_6502, BINFMT_O65, CTNone }, { "atmos", CPU_6502, BINFMT_BINARY, CTNone }, { "nes", CPU_6502, BINFMT_BINARY, CTNone }, @@ -211,7 +210,6 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "sim65c02", CPU_65C02, BINFMT_BINARY, CTNone }, { "pce", CPU_HUC6280, BINFMT_BINARY, CTNone }, { "gamate", CPU_6502, BINFMT_BINARY, CTNone }, - { "supervision", CPU_65SC02, BINFMT_BINARY, CTNone }, { "c65", CPU_4510, BINFMT_BINARY, CTPET }, }; diff --git a/src/common/target.h b/src/common/target.h index 1e54784b1..054c4f2ba 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -67,21 +67,21 @@ typedef enum { TGT_CBM610, TGT_OSIC1P, TGT_PET, + TGT_BBC, TGT_APPLE2, TGT_APPLE2ENH, - TGT_ATMOS, - TGT_BBC, + TGT_GEOS_CBM, TGT_CREATIVISION, TGT_GEOS_APPLE, - TGT_GEOS_CBM, TGT_LUNIX, - TGT_LYNX, + TGT_ATMOS, TGT_NES, + TGT_SUPERVISION, + TGT_LYNX, TGT_SIM6502, TGT_SIM65C02, TGT_PCENGINE, TGT_GAMATE, - TGT_SUPERVISION, TGT_C65, TGT_COUNT /* Number of target systems */ } target_t; From e6359ec01947e75ed209d145f063da1692ee9c71 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Mon, 6 Feb 2017 20:59:52 +0100 Subject: [PATCH 05/11] Add initial creativision.sgml, contributed by Stefan Haubenthal. --- doc/creativision.sgml | 174 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 doc/creativision.sgml diff --git a/doc/creativision.sgml b/doc/creativision.sgml new file mode 100644 index 000000000..5b69da75a --- /dev/null +++ b/doc/creativision.sgml @@ -0,0 +1,174 @@ + + +
+ +VTech Creativision (aka Funvision) specific information for cc65 +<author><url url="mailto:polluks+cc65@sdf.lonestar.org" name="Stefan A. Haubenthal"> +<date>2016-04-14 + +<abstract> +An overview over the Creativision runtime system as it is implemented for the +cc65 C compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview<p> + +This file contains an overview of the Creativision runtime system as it comes +with the cc65 C compiler. It describes the memory layout, Creativision specific header +files, available drivers, and any pitfalls specific to that platform. + +Please note that Creativision specific functions are just mentioned here, they are +described in detail in the separate <url url="funcref.html" name="function +reference">. Even functions marked as "platform dependent" may be available on +more than one platform. Please see the function reference for more information. + + +<sect>Binary format<p> + +The standard binary output format generated by the linker for the Creativision target +is a 4 kbyte machine language program. It is of course possible to change +this behaviour by using one of the different linker configs. + +<sect>Memory layout<p> + +cc65 generated programs with the default setup run with the I/O area enabled, +which gives a usable memory range of $B000 - $BEFF. +More ROM may need additional bankswitching code. + +Special locations: + +<descrip> + <tag/Text screen/ + The text screen is located at VRAM $1000. + + <tag/Stack/ + The C runtime stack is located at $3FF and growing downwards. + + <tag/Heap/ + The C heap is located at the end of the program and grows towards the C + runtime stack. + +</descrip><p> + + + +<sect>Platform specific header files<p> + +Programs containing Creativision specific code may use the <tt/creativision.h/ header file. + + +<sect1>Creativision specific functions<p> + +<itemize> +<item>bios_playsound +<item>joystate +<item>psg_delay +<item>psg_outb +<item>psg_silence +</itemize> + + + +<!--<sect1>Hardware access<p> + +The following pseudo variables declared in the <tt/creativision.inc/ include file do +allow access to hardware located in the address space. + +<descrip> + + <tag><tt/VDP/</tag> + The <tt/VDP/ defines allow access to the video chip. + +</descrip><p> + +<descrip> + + <tag><tt/PIA/</tag> + The <tt/PIA/ defines allow access to the I/O chip. + +</descrip><p>--> + + + +<sect>Loadable drivers<p> + +<sect1>Graphics drivers<p> + +No graphics drivers are currently available for the Creativision. + + +<sect1>Extended memory drivers<p> + +No extended memory drivers are currently available for the Creativision. + + +<sect1>Joystick drivers<p> + +No joystick drivers are currently available for the Creativision but <tt/joystate()/. + + +<sect1>Mouse drivers<p> + +No mouse drivers are currently available for the Creativision. + + +<sect1>RS232 device drivers<p> + +No communication port drivers are currently available for the Creativision. + + + +<sect>Limitations<p> + +<sect1>Disk I/O<p> + +The existing library for the Creativision doesn't implement C file +I/O. There are even no hacks for the <tt/read()/ and <tt/write()/ routines. + +To be more concrete, this limitation means that you cannot use any of the +following functions (and a few others): + +<itemize> +<item>fclose +<item>fopen +<item>fread +<item>fprintf +<item>fputc +<item>fscanf +<item>fwrite +<item>... +</itemize> + + + +<sect>Other hints<p> + + + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> From c33383e6de5beb17931c4375307071653fb9cdd0 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Mon, 6 Feb 2017 21:06:08 +0100 Subject: [PATCH 06/11] Add Creativision to README.md and html index --- README.md | 1 + doc/index.sgml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index b62ac761d..359fdaa08 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ including - the NEC PC-Engine (aka TurboGrafx-16). - the Nintendo Entertainment System (NES) console. - the Watara Supervision console. +- the VTech Creativision console. - the Oric Atmos. - the Lynx console. - the Ohio Scientific Challenger 1P. diff --git a/doc/index.sgml b/doc/index.sgml index 9b7ab794e..2a5c8894f 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -140,6 +140,9 @@ <tag><htmlurl url="cbm610.html" name="cbm610.html"></tag> Topics specific to the Commodore 610. + <tag><htmlurl url="creativision.html" name="creativision.html"></tag> + Topics specific to the Creativision Console. + <tag><htmlurl url="lynx.html" name="lynx.html"></tag> Topics specific to the Atari Lynx Game Console. From 38451fa8a4d6a1e4141f24bb50e774582ac564af Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 8 Feb 2017 14:34:35 +0100 Subject: [PATCH 07/11] intermediate check-in -- creativision joystick driver --- asminc/creativision.inc | 6 +- libsrc/creativision/joy/creativision-stdjoy.s | 191 ++++++++++++++++++ libsrc/creativision/joy_stat_stddrv.s | 12 ++ libsrc/creativision/libref.s | 3 +- 4 files changed, 207 insertions(+), 5 deletions(-) create mode 100644 libsrc/creativision/joy/creativision-stdjoy.s create mode 100644 libsrc/creativision/joy_stat_stddrv.s diff --git a/asminc/creativision.inc b/asminc/creativision.inc index 624b65e8f..bd30bc462 100644 --- a/asminc/creativision.inc +++ b/asminc/creativision.inc @@ -29,10 +29,10 @@ CH_URCORNER = 36 CH_LLCORNER = 37 CH_LRCORNER = 38 -;** I/O +;** I/O (Zero-page variables) ZP_KEYBOARD = $10 ZP_JOY0_DIR = $11 ZP_JOY1_DIR = $13 -ZP_JOY_LBUTTONS = $16 -ZP_JOY_RBUTTONS = $17 +ZP_JOY0_BUTTONS = $16 +ZP_JOY1_BUTTONS = $17 diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s new file mode 100644 index 000000000..f24a8045b --- /dev/null +++ b/libsrc/creativision/joy/creativision-stdjoy.s @@ -0,0 +1,191 @@ +; +; Standard joystick driver for the Creativision. +; +; Christian Groessler, 2017-02-06 +; + + .include "zeropage.inc" + + .include "joy-kernel.inc" + .include "joy-error.inc" + .include "creativision.inc" + + .macpack module + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + + module_header _creativisionstd_joy + +; Driver signature + + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number + +; Library reference + + .addr $0000 + +; Button state masks (8 values) + + .byte $10 ; JOY_UP + .byte $04 ; JOY_DOWN + .byte $20 ; JOY_LEFT + .byte $08 ; JOY_RIGHT + .byte $01 ; JOY_FIRE (button #1) + .byte $02 ; JOY_FIRE2 (button #2) + .byte $00 ; Future expansion + .byte $00 ; Future expansion + +; Jump table. + + .addr INSTALL + .addr UNINSTALL + .addr COUNT + .addr READJOY + .addr 0 ; IRQ entry not used + +; ------------------------------------------------------------------------ +; Constants + +JOY_COUNT = 2 ; Number of joysticks we support + +; ------------------------------------------------------------------------ +; Code + + .code + +; ------------------------------------------------------------------------ +; INSTALL routine. Is called after the driver is loaded into memory. If +; possible, check if the hardware is present and determine the amount of +; memory available. +; Must return an JOY_ERR_xx code in a/x. +; + +INSTALL: + lda #JOY_ERR_OK + ldx #0 +; rts ; Fall through + +; ------------------------------------------------------------------------ +; UNINSTALL routine. Is called before the driver is removed from memory. +; Can do cleanup or whatever. Must not return anything. +; + +UNINSTALL: + rts + + +; ------------------------------------------------------------------------ +; COUNT: Return the total number of available joysticks in a/x. +; + +COUNT: + lda #<JOY_COUNT + ldx #>JOY_COUNT + rts + +; ------------------------------------------------------------------------ +; READ: Read a particular joystick passed in A. +; + +READJOY: + and #1 ; fix joystick number + bne READJOY_1 ; read right joystick + +; Read left joystick + + ldx ZP_JOY0_DIR + lda ZP_JOY0_BUTTONS + jmp convert ; convert joystick state to sane cc65 values + +; Read right joystick + +READJOY_1: + + ldx ZP_JOY1_DIR + lda ZP_JOY1_BUTTONS + lsr a + lsr a + ;jmp convert ; convert joystick state to sane cc65 values + ; fall thru... + +; ------------------------------------------------------------------------ +; convert: make runtime lib compatible values +; A - buttons +; X - direction +; + +convert: + ldy #0 + sty retval ; initialize return value + +; ------ +; buttons: + ; Port values are for the left hand joystick (right hand joystick + ; values were shifted to the right to be identical). + ; Why are there two bits indicating a pressed trigger? + ; According to the "Second book of programs for the Dick Smith Wizard" + ; (pg. 88ff), the left hand fire button gives the value of + ; %00010001 and the right hand button gives %00100010 + ; Why two bits? Am I missing something? Can there be cases that just + ; one of those bits is set? + ; We just test if any of those two bits is not zero... + + tay + and #%00010001 + beq cnv_1 + + inc retval ; left button pressed + +cnv_1: tya + and #%00100010 + beq cnv_2 + + lda #$02 + ora retval + sta retval ; right button pressed + +; ------ +; direction: +cnv_2: txa + ; tested with https://sourceforge.net/projects/creativisionemulator + ; $49 - %01001001 - up + ; $41 - %01000001 - down + ; $4D - %01001101 - left + ; $45 - %01000101 - right + ; + ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different + ; ignored for now... + ; $85 - %10000101 - up + right + ; $8D - %10001101 - down + left + ; $89 - %10001001 - up + left + ; $85 - %10000101 - down + right (emulator bug?) + + bit testbit ; bit #0 set? + beq done ; no, no direction + + and #%00001100 ; mask out other bits + tax + lda #%00000100 ; init bitmask +loop: dex + bmi done2 + asl a + bne loop + +done2: ora retval + rts + +done: lda retval + rts + +; ------------------------------------------------------------------------ +; + .data +testbit:.byte $01 + +; ------------------------------------------------------------------------ +; + .bss +retval: .res 0 diff --git a/libsrc/creativision/joy_stat_stddrv.s b/libsrc/creativision/joy_stat_stddrv.s new file mode 100644 index 000000000..fc458641c --- /dev/null +++ b/libsrc/creativision/joy_stat_stddrv.s @@ -0,0 +1,12 @@ +; +; Address of the static standard joystick driver +; +; Christian Groessler, 2017-02-06 +; +; const void joy_static_stddrv[]; +; + + .export _joy_static_stddrv + .import _creativisionstd_joy + +_joy_static_stddrv := _creativisionstd_joy diff --git a/libsrc/creativision/libref.s b/libsrc/creativision/libref.s index b642da80a..19e7e778f 100644 --- a/libsrc/creativision/libref.s +++ b/libsrc/creativision/libref.s @@ -2,8 +2,7 @@ ; Oliver Schmidt, 2013-05-31 ; - .export joy_libref, tgi_libref + .export joy_libref .import _exit joy_libref := _exit -tgi_libref := _exit From c0803ed53ac5113b8065e07a0c91eebf507975f5 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 14 Feb 2017 23:52:44 +0100 Subject: [PATCH 08/11] fix indentation --- libsrc/creativision/cputc.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/creativision/cputc.s b/libsrc/creativision/cputc.s index 208009ebd..ff60494b9 100644 --- a/libsrc/creativision/cputc.s +++ b/libsrc/creativision/cputc.s @@ -50,7 +50,7 @@ advance: iny cpy #SCREEN_COLS bne L3 - inc CURSOR_Y ; new line + inc CURSOR_Y ; new line ldy #0 ; + cr L3: sty CURSOR_X jmp plot From b858b0d6230d263dedec8e741b01cd8a5602cb59 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 15 Feb 2017 15:37:06 +0100 Subject: [PATCH 09/11] Add joystick driver to documentation. --- doc/creativision.sgml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/creativision.sgml b/doc/creativision.sgml index 5b69da75a..64623b3b2 100644 --- a/doc/creativision.sgml +++ b/doc/creativision.sgml @@ -66,7 +66,6 @@ Programs containing Creativision specific code may use the <tt/creativision.h/ h <itemize> <item>bios_playsound -<item>joystate <item>psg_delay <item>psg_outb <item>psg_silence @@ -109,8 +108,12 @@ No extended memory drivers are currently available for the Creativision. <sect1>Joystick drivers<p> -No joystick drivers are currently available for the Creativision but <tt/joystate()/. +<descrip> + <tag><tt/creativision-stdjoy.joy (creativisionstd_joy)/</tag> + A joystick driver for the standard joystick is available. + +</descrip><p> <sect1>Mouse drivers<p> From e6530d68dd51c9c310b7a9aa346bb19d126b4910 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 15 Feb 2017 15:45:49 +0100 Subject: [PATCH 10/11] Fix joystick driver. Add interruptor support. Note that the joystick driver doesn't support combined movements (like left/up or right/down). This should be fixed. --- asminc/creativision.inc | 4 + include/creativision.h | 65 +++++++++------- libsrc/creativision/crt0.s | 8 +- libsrc/creativision/irq.s | 40 ++++++++++ libsrc/creativision/joy/creativision-stdjoy.s | 76 ++++++++++--------- testcode/lib/joy-test.c | 12 +-- 6 files changed, 132 insertions(+), 73 deletions(-) create mode 100644 libsrc/creativision/irq.s diff --git a/asminc/creativision.inc b/asminc/creativision.inc index bd30bc462..59b26101b 100644 --- a/asminc/creativision.inc +++ b/asminc/creativision.inc @@ -36,3 +36,7 @@ ZP_JOY1_DIR = $13 ZP_JOY0_BUTTONS = $16 ZP_JOY1_BUTTONS = $17 +;** BIOS +BIOS_IRQ1_ADDR = $FF3F +BIOS_IRQ2_ADDR = $FF52 +BIOS_NMI_RESET_ADDR = $F808 diff --git a/include/creativision.h b/include/creativision.h index adaa1caab..5cc99b7af 100644 --- a/include/creativision.h +++ b/include/creativision.h @@ -1,9 +1,38 @@ -/* CreatiVision Header */ +/*****************************************************************************/ +/* */ +/* creativision.h */ +/* */ +/* Creativision system specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2013 cvemu */ +/* (C) 2017 Christian Groessler <chris@groessler.org> */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ #ifndef _CVISION_H - #define _CVISION_H +/* Character codes */ #define CH_VLINE 33 #define CH_HLINE 34 #define CH_ULCORNER 35 @@ -11,12 +40,13 @@ #define CH_LLCORNER 37 #define CH_LRCORNER 38 +/* no support for dynamically loadable drivers */ #define DYN_DRV 0 /* Colours - from TMS9918 */ #define C_TRANSPARENT 0 #define C_BLACK 1 -#define C_MED_GREEN 2 +#define C_MED_GREEN 2 #define C_LIGHT_GREEN 3 #define C_DARK_BLUE 4 #define C_LIGHT_BLUE 5 @@ -31,29 +61,10 @@ #define C_GREY 14 #define C_WHITE 15 -/* Joystick states */ -#define JOY_UP 5 -#define JOY_DOWN 1 -#define JOY_LEFT 7 -#define JOY_RIGHT 3 -#define JOY_LEFT_UP 6 -#define JOY_LEFT_DOWN 8 -#define JOY_RIGHT_UP 4 -#define JOY_RIGHT_DOWN 2 -#define JOY_LBUTTON 1 -#define JOY_RBUTTON 2 - -/* Joystick values */ -#define JOY_LEFT_DIR 1 -#define JOY_RIGHT_DIR 2 -#define JOY_LEFT_BUTTONS 3 -#define JOY_RIGHT_BUTTONS 4 - /* Protos */ -void __fastcall__ psg_outb( unsigned char b ); -void __fastcall__ psg_delay( unsigned char b ); -void psg_silence( void ); -void __fastcall__ bios_playsound( void *a, unsigned char b); -unsigned char __fastcall__ joystate( unsigned char which ); +void __fastcall__ psg_outb(unsigned char b); +void __fastcall__ psg_delay(unsigned char b); +void psg_silence(void); +void __fastcall__ bios_playsound(void *a, unsigned char b); -#endif +#endif /* #ifndef _CVISION_H */ diff --git a/libsrc/creativision/crt0.s b/libsrc/creativision/crt0.s index ccae38e81..6faec38eb 100644 --- a/libsrc/creativision/crt0.s +++ b/libsrc/creativision/crt0.s @@ -4,11 +4,13 @@ .export _exit .export __STARTUP__ : absolute = 1 ; Mark as startup + .export irq2 .import zerobss, copydata .import initlib, donelib, callmain .import __VECTORS_LOAD__, __VECTORS_RUN__, __VECTORS_SIZE__ .import __ZP_LAST__, __STACKSIZE__, __RAM_START__ + .include "creativision.inc" .include "zeropage.inc" ; ------------------------------------------------------------------------ @@ -61,8 +63,8 @@ loop: jmp loop .segment "VECTORS" -irq1: jmp $FF3F -irq2: jmp $FF52 +irq1: jmp BIOS_IRQ1_ADDR +irq2: jmp BIOS_IRQ2_ADDR ; ------------------------------------------------------------------------ ; Define CART setup values for BIOS. @@ -92,7 +94,7 @@ irq2: jmp $FF52 ; BIOS Vector after NMI or RESET ; Keeping with retail cartridges, we jump back to BIOS ROM and have it ; setup zeropage etc, and show the Creativision logo and copyright. - .addr $F808 + .addr BIOS_NMI_RESET_ADDR ; BIOS Short Interrupt Handler ; Vectored from BIOS ROM:FE2C. This should contain a pointer to the user's diff --git a/libsrc/creativision/irq.s b/libsrc/creativision/irq.s new file mode 100644 index 000000000..f154c9199 --- /dev/null +++ b/libsrc/creativision/irq.s @@ -0,0 +1,40 @@ +; +; IRQ handling (CreatiVision version) +; + + .export initirq, doneirq + .import callirq, irq2 + + .include "creativision.inc" + +; ------------------------------------------------------------------------ + +.segment "ONCE" + +initirq: + lda #<IRQStub + ldx #>IRQStub + jmp setvec + +; ------------------------------------------------------------------------ + +.code + +doneirq: + lda #<BIOS_IRQ2_ADDR + ldx #>BIOS_IRQ2_ADDR +setvec: sei + sta irq2+1 + stx irq2+2 + cli + rts + +; ------------------------------------------------------------------------ + +.segment "CODE" + +IRQStub: + cld ; Just to be sure + jsr callirq ; Call the functions + jmp BIOS_IRQ2_ADDR ; Jump to the BIOS IRQ vector + diff --git a/libsrc/creativision/joy/creativision-stdjoy.s b/libsrc/creativision/joy/creativision-stdjoy.s index f24a8045b..37b927d08 100644 --- a/libsrc/creativision/joy/creativision-stdjoy.s +++ b/libsrc/creativision/joy/creativision-stdjoy.s @@ -49,7 +49,7 @@ ; ------------------------------------------------------------------------ ; Constants -JOY_COUNT = 2 ; Number of joysticks we support +JOY_COUNT = 2 ; Number of joysticks we support ; ------------------------------------------------------------------------ ; Code @@ -66,7 +66,7 @@ JOY_COUNT = 2 ; Number of joysticks we support INSTALL: lda #JOY_ERR_OK ldx #0 -; rts ; Fall through +; rts ; Fall through ; ------------------------------------------------------------------------ ; UNINSTALL routine. Is called before the driver is removed from memory. @@ -91,14 +91,14 @@ COUNT: ; READJOY: - and #1 ; fix joystick number - bne READJOY_1 ; read right joystick + and #1 ; fix joystick number + bne READJOY_1 ; read right joystick ; Read left joystick ldx ZP_JOY0_DIR lda ZP_JOY0_BUTTONS - jmp convert ; convert joystick state to sane cc65 values + jmp convert ; convert joystick state to sane cc65 values ; Read right joystick @@ -108,8 +108,8 @@ READJOY_1: lda ZP_JOY1_BUTTONS lsr a lsr a - ;jmp convert ; convert joystick state to sane cc65 values - ; fall thru... + ;jmp convert ; convert joystick state to sane cc65 values + ; fall thru... ; ------------------------------------------------------------------------ ; convert: make runtime lib compatible values @@ -119,7 +119,7 @@ READJOY_1: convert: ldy #0 - sty retval ; initialize return value + sty retval ; initialize return value ; ------ ; buttons: @@ -127,7 +127,7 @@ convert: ; values were shifted to the right to be identical). ; Why are there two bits indicating a pressed trigger? ; According to the "Second book of programs for the Dick Smith Wizard" - ; (pg. 88ff), the left hand fire button gives the value of + ; (pg. 88ff), the left hand fire button gives the value of ; %00010001 and the right hand button gives %00100010 ; Why two bits? Am I missing something? Can there be cases that just ; one of those bits is set? @@ -137,7 +137,7 @@ convert: and #%00010001 beq cnv_1 - inc retval ; left button pressed + inc retval ; left button pressed cnv_1: tya and #%00100010 @@ -145,45 +145,47 @@ cnv_1: tya lda #$02 ora retval - sta retval ; right button pressed + sta retval ; right button pressed ; ------ ; direction: cnv_2: txa - ; tested with https://sourceforge.net/projects/creativisionemulator - ; $49 - %01001001 - up - ; $41 - %01000001 - down - ; $4D - %01001101 - left - ; $45 - %01000101 - right - ; - ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different - ; ignored for now... - ; $85 - %10000101 - up + right - ; $8D - %10001101 - down + left - ; $89 - %10001001 - up + left - ; $85 - %10000101 - down + right (emulator bug?) + ; tested with https://sourceforge.net/projects/creativisionemulator + ; $49 - %01001001 - up + ; $41 - %01000001 - down + ; $4D - %01001101 - left + ; $45 - %01000101 - right + ; + ; are these correct? "Second book of programs for the Dick Smith Wizard" pg. 85 says something different + ; ignored for now... + ; $85 - %10000101 - up + right + ; $8D - %10001101 - down + left + ; $89 - %10001001 - up + left + ; $85 - %10000101 - down + right (emulator bug?) - bit testbit ; bit #0 set? - beq done ; no, no direction + bit testbit ; bit #0 set? + beq done ; no, no direction - and #%00001100 ; mask out other bits - tax - lda #%00000100 ; init bitmask -loop: dex - bmi done2 - asl a - bne loop + and #%00001100 ; mask out other bits + lsr a + lsr a + tax + lda #%00000100 ; init bitmask +loop: dex + bmi done2 + asl a + bne loop -done2: ora retval - rts +done2: ora retval + rts -done: lda retval - rts +done: lda retval + rts ; ------------------------------------------------------------------------ ; .data -testbit:.byte $01 +testbit:.byte $01 ; ------------------------------------------------------------------------ ; diff --git a/testcode/lib/joy-test.c b/testcode/lib/joy-test.c index 0a5c80902..fc751ebdc 100644 --- a/testcode/lib/joy-test.c +++ b/testcode/lib/joy-test.c @@ -46,7 +46,7 @@ int main (void) clrscr (); count = joy_count (); -#ifdef __ATARI5200__ +#if defined(__ATARI5200__) || defined(__CREATIVISION__) cprintf ("JOYSTICKS: %d", count); #else cprintf ("Driver supports %d joystick(s)", count); @@ -55,13 +55,13 @@ int main (void) for (i = 0; i < count; ++i) { gotoxy (0, i+1); j = joy_read (i); -#ifdef __ATARI5200__ +#if defined(__ATARI5200__) || defined(__CREATIVISION__) cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s%-3s", i, - (j & joy_masks[JOY_UP])? " U " : " u ", - (j & joy_masks[JOY_DOWN])? " D " : " d ", - (j & joy_masks[JOY_LEFT])? " L " : " l ", - (j & joy_masks[JOY_RIGHT])? " R " : " r ", + (j & joy_masks[JOY_UP])? " U " : " ", + (j & joy_masks[JOY_DOWN])? " D " : " ", + (j & joy_masks[JOY_LEFT])? " L " : " ", + (j & joy_masks[JOY_RIGHT])? " R " : " ", (j & joy_masks[JOY_FIRE])? " 1 " : " ", (j & joy_masks[JOY_FIRE2])? " 2 " : " "); #else From ddae920ee9e7cbfc3b9cd7fc8319102fe8ca3a62 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 15 Feb 2017 15:53:57 +0100 Subject: [PATCH 11/11] remove old joystick code --- libsrc/creativision/joy.s | 58 --------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 libsrc/creativision/joy.s diff --git a/libsrc/creativision/joy.s b/libsrc/creativision/joy.s deleted file mode 100644 index eb0bc6594..000000000 --- a/libsrc/creativision/joy.s +++ /dev/null @@ -1,58 +0,0 @@ -;* -;* Creativision Joystick Function -;* -;* unsigned char __fastcall__ joystate(unsigned char joy); -;* -;* JOY_1 -> Return Left Joystick direction -;* JOY_2 -> Return Right Joystick direction -;* JOY_3 -> Return Left Joystick buttons -;* JOY_4 -> Return Right Joystick buttons -;* -;* Will only work if interrupts are enabled. - - .export _joystate - .include "creativision.inc" - -_joystate: - cmp #1 ; Left Direction - bne l1 - - lda $11 - beq l5 - and #$0F - lsr a - tax - inx - txa - rts - -l1: cmp #2 ; Right Direction - bne l2 - - lda $13 - beq l5 - and #$0F - lsr a - tax - inx - txa - rts - -l2: cmp #3 ; Left Buttons - bne l3 - - lda $16 - beq l5 - and #$0F - rts - -l3: cmp #4 - bne l4 - - lda $17 - beq l5 - and #$0F - rts - -l4: lda #0 -l5: rts