conio and most other stuff working now

This commit is contained in:
mrdudz
2015-11-29 01:14:59 +01:00
parent 88e7b5776a
commit 9fbf8a4299
35 changed files with 2205 additions and 737 deletions

16
libsrc/gamate/_scrsize.s Normal file
View File

@@ -0,0 +1,16 @@
;
; Screen size variables
;
.include "gamate.inc"
.export screensize
screensize:
ldx xsize
ldy ysize
rts
.rodata
.export xsize, ysize
xsize: .byte charsperline
ysize: .byte screenrows

32
libsrc/gamate/chline.s Normal file
View File

@@ -0,0 +1,32 @@
;
; Ullrich von Bassewitz, 08.08.1998
;
; 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 "gamate.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

33
libsrc/gamate/clock.s Normal file
View File

@@ -0,0 +1,33 @@
;
; clock_t clock (void);
;
.include "gamate.inc"
.include "extzp.inc"
.export _clock
.forceimport ticktock
.importzp sreg
.constructor initclock
.proc _clock
lda tickcount+3
sta sreg+1
lda tickcount+2
sta sreg
ldx tickcount+1
lda tickcount
rts
.endproc
.segment "INIT"
initclock:
lda #0
ldx #3
@lp: sta tickcount,x
dex
bpl @lp
rts

35
libsrc/gamate/clrscr.s Normal file
View File

@@ -0,0 +1,35 @@
.include "gamate.inc"
.include "extzp.inc"
.import plot
.export _clrscr
_clrscr:
ldy #$0
rowloop:
sty LCD_X
lda #0
sta LCD_Y
ldx #$0
colloop:
sta LCD_DATA
inx
bne colloop
iny
bne rowloop
; Go to the home position.
sta CURS_X
sta CURS_Y
jmp plot
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import initconio
conio_init = initconio

34
libsrc/gamate/color.s Normal file
View File

@@ -0,0 +1,34 @@
;
; 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
.include "gamate.inc"
.include "extzp.inc"
_textcolor:
ldx CHARCOLOR ; get old value
sta CHARCOLOR ; set new value
txa
rts
_bgcolor:
ldx BGCOLOR ; get old value
sta BGCOLOR ; set new value
txa
rts
_bordercolor:
lda #0
tax
rts
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import initconio
conio_init = initconio

31
libsrc/gamate/conio.s Normal file
View File

@@ -0,0 +1,31 @@
.include "gamate.inc"
.include "extzp.inc"
.import colors
.importzp ptr1, tmp1
.constructor initconio
.macpack longbranch
.segment "INIT"
initconio:
; FIXME
lda #0
sta LCD_XPOS
sta LCD_YPOS
lda #LCD_MODE_INC_Y
sta LCD_MODE
lda #COLOR_BLACK
sta CHARCOLOR
lda #COLOR_WHITE
sta BGCOLOR
rts
.segment "RODATA"
.export fontdata
fontdata:
.include "vga.inc"

153
libsrc/gamate/cputc.s Normal file
View File

@@ -0,0 +1,153 @@
;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
;
.export _cputcxy, _cputc, cputdirect, putchar
.export newline, plot
.import popa, _gotoxy
.import PLOT
.import xsize
.import fontdata
.import _plotlo
.importzp tmp3,tmp4
.importzp ptr3
.include "gamate.inc"
.include "extzp.inc"
_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 CURS_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 CURS_X
iny
cpy xsize
bne L3
jsr newline ; new line
ldy #0 ; + cr
L3: sty CURS_X
jmp plot
newline:
inc CURS_Y
; Set cursor position, calculate RAM pointers
plot: ldy CURS_X
ldx CURS_Y
clc
jmp PLOT ; Set the new cursor
; Write one character to the screen without doing anything else, return X
; position in Y
putchar:
; FIXME
; ora RVS ; Set revers bit
; sty temp_y
; stx temp_x
; sta temp_a
; lda temp_a
sta ptr3
txa
pha
lda #0
sta ptr3+1
; * 8
asl ptr3
rol ptr3+1
asl ptr3
rol ptr3+1
asl ptr3
rol ptr3+1
lda ptr3
clc
adc #<(fontdata-$f8)
sta ptr3
lda ptr3+1
adc #>(fontdata-$f8)
sta ptr3+1
lda CHARCOLOR
and #1
beq @skip_plane1
lda #LCD_XPOS_PLANE1
clc
adc CURS_X
sta LCD_X
ldy #$f8
@copylp1:
lda (ptr3),y
eor RVS
sta LCD_DATA
iny
bne @copylp1
@skip_plane1:
lda CHARCOLOR
and #2
beq @skip_plane2
lda #LCD_XPOS_PLANE2
clc
adc CURS_X
sta LCD_X
ldx CURS_Y
lda _plotlo,x
sta LCD_Y
ldy #$f8
@copylp2:
lda (ptr3),y
eor RVS
sta LCD_DATA
iny
bne @copylp2
@skip_plane2:
pla
tax
ldy CURS_X
rts
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import initconio
conio_init = initconio

View File

@@ -1,16 +1,78 @@
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import reset, irq, nmi ; FIXME
.import initlib, donelib, callmain
.import push0, _main, zerobss, copydata
.import IRQStub
; Linker generated symbols
.import __RAM_START__, __RAM_SIZE__
.import __ROM_START__, __ROM_SIZE__
.import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__
.import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__
.import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__
.include "zeropage.inc"
.include "gamate.inc"
.segment "STARTUP"
checksum:
.word 0
.byte 1, 0, 1
.byte "COPYRIGHT BIT CORPORATION", 0, $ff
jmp reset
jmp nmi
jmp irq
.word 0 ; +00 checksum from 7000-7fff (simple 8bit adds)
.byte 1, 0, 1 ; +02 flags
.byte "COPYRIGHT BIT CORPORATION", 0, $ff ; +05 copyright
; system vectors
jmp reset ; +20 reset entry
jmp nmi ; +23 nmi entry
jmp IRQStub ; +26 irq entry (135 hz)
;-------------------------------------------------------------------------------
reset:
; setup the CPU and System-IRQ
; Initialize CPU
sei
cld
; Setup stack and memory mapping
ldx #$FF ; Stack top ($01FF)
txs
; Clear the BSS data
jsr zerobss
; Copy the .data segment to RAM
jsr copydata
; setup the stack
lda #<(__RAM_START__+__RAM_SIZE__)
sta sp
lda #>(__RAM_START__+__RAM_SIZE__)
sta sp + 1
; Call module constructors
jsr initlib
cli ; allow IRQ only after constructors have run
; Pass an empty command line
jsr push0 ; argc
jsr push0 ; argv
ldy #4 ; Argument size
jsr _main ; call the users code
; Call module destructors. This is also the _exit entry.
_exit:
jsr donelib ; Run module destructors
; reset (start over)
jmp reset
.export initmainargs
initmainargs:
rts
;-------------------------------------------------------------------------------
nmi:
rts

161
libsrc/gamate/ctype.s Normal file
View File

@@ -0,0 +1,161 @@
;
; Stefan Haubenthal with minor changes from Ullrich von Bassewitz, 2003-05-02
;
; Character specification table.
;
.include "ctype.inc"
; 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.
__ctype:
.repeat 2
.byte CT_CTRL ; 0/00 ___ctrl_@___
.byte CT_CTRL ; 1/01 ___ctrl_A___
.byte CT_CTRL ; 2/02 ___ctrl_B___
.byte CT_CTRL ; 3/03 ___ctrl_C___
.byte CT_CTRL ; 4/04 ___ctrl_D___
.byte CT_CTRL ; 5/05 ___ctrl_E___
.byte CT_CTRL ; 6/06 ___ctrl_F___
.byte CT_CTRL ; 7/07 ___ctrl_G___
.byte CT_CTRL ; 8/08 ___ctrl_H___
.byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB
; 9/09 ___ctrl_I___
.byte CT_CTRL | CT_OTHER_WS ; 10/0a ___ctrl_J___
.byte CT_CTRL | CT_OTHER_WS ; 11/0b ___ctrl_K___
.byte CT_CTRL | CT_OTHER_WS ; 12/0c ___ctrl_L___
.byte CT_CTRL | CT_OTHER_WS ; 13/0d ___ctrl_M___
.byte CT_CTRL ; 14/0e ___ctrl_N___
.byte CT_CTRL ; 15/0f ___ctrl_O___
.byte CT_CTRL ; 16/10 ___ctrl_P___
.byte CT_CTRL ; 17/11 ___ctrl_Q___
.byte CT_CTRL ; 18/12 ___ctrl_R___
.byte CT_CTRL ; 19/13 ___ctrl_S___
.byte CT_CTRL ; 20/14 ___ctrl_T___
.byte CT_CTRL ; 21/15 ___ctrl_U___
.byte CT_CTRL ; 22/16 ___ctrl_V___
.byte CT_CTRL ; 23/17 ___ctrl_W___
.byte CT_CTRL ; 24/18 ___ctrl_X___
.byte CT_CTRL ; 25/19 ___ctrl_Y___
.byte CT_CTRL ; 26/1a ___ctrl_Z___
.byte CT_CTRL ; 27/1b ___ctrl_[___
.byte CT_CTRL ; 28/1c ___ctrl_\___
.byte CT_CTRL ; 29/1d ___ctrl_]___
.byte CT_CTRL ; 30/1e ___ctrl_^___
.byte CT_CTRL ; 31/1f ___ctrl_____
.byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___
.byte CT_NONE ; 33/21 _____!_____
.byte CT_NONE ; 34/22 _____"_____
.byte CT_NONE ; 35/23 _____#_____
.byte CT_NONE ; 36/24 _____$_____
.byte CT_NONE ; 37/25 _____%_____
.byte CT_NONE ; 38/26 _____&_____
.byte CT_NONE ; 39/27 _____'_____
.byte CT_NONE ; 40/28 _____(_____
.byte CT_NONE ; 41/29 _____)_____
.byte CT_NONE ; 42/2a _____*_____
.byte CT_NONE ; 43/2b _____+_____
.byte CT_NONE ; 44/2c _____,_____
.byte CT_NONE ; 45/2d _____-_____
.byte CT_NONE ; 46/2e _____._____
.byte CT_NONE ; 47/2f _____/_____
.byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____
.byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____
.byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____
.byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____
.byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____
.byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____
.byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____
.byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____
.byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____
.byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____
.byte CT_NONE ; 58/3a _____:_____
.byte CT_NONE ; 59/3b _____;_____
.byte CT_NONE ; 60/3c _____<_____
.byte CT_NONE ; 61/3d _____=_____
.byte CT_NONE ; 62/3e _____>_____
.byte CT_NONE ; 63/3f _____?_____
.byte CT_NONE ; 64/40 _____@_____
.byte CT_UPPER | CT_XDIGIT ; 65/41 _____A_____
.byte CT_UPPER | CT_XDIGIT ; 66/42 _____B_____
.byte CT_UPPER | CT_XDIGIT ; 67/43 _____C_____
.byte CT_UPPER | CT_XDIGIT ; 68/44 _____D_____
.byte CT_UPPER | CT_XDIGIT ; 69/45 _____E_____
.byte CT_UPPER | CT_XDIGIT ; 70/46 _____F_____
.byte CT_UPPER ; 71/47 _____G_____
.byte CT_UPPER ; 72/48 _____H_____
.byte CT_UPPER ; 73/49 _____I_____
.byte CT_UPPER ; 74/4a _____J_____
.byte CT_UPPER ; 75/4b _____K_____
.byte CT_UPPER ; 76/4c _____L_____
.byte CT_UPPER ; 77/4d _____M_____
.byte CT_UPPER ; 78/4e _____N_____
.byte CT_UPPER ; 79/4f _____O_____
.byte CT_UPPER ; 80/50 _____P_____
.byte CT_UPPER ; 81/51 _____Q_____
.byte CT_UPPER ; 82/52 _____R_____
.byte CT_UPPER ; 83/53 _____S_____
.byte CT_UPPER ; 84/54 _____T_____
.byte CT_UPPER ; 85/55 _____U_____
.byte CT_UPPER ; 86/56 _____V_____
.byte CT_UPPER ; 87/57 _____W_____
.byte CT_UPPER ; 88/58 _____X_____
.byte CT_UPPER ; 89/59 _____Y_____
.byte CT_UPPER ; 90/5a _____Z_____
.byte CT_NONE ; 91/5b _____[_____
.byte CT_NONE ; 92/5c _____\_____
.byte CT_NONE ; 93/5d _____]_____
.byte CT_NONE ; 94/5e _____^_____
.byte CT_NONE ; 95/5f _UNDERLINE_
.byte CT_NONE ; 96/60 ___grave___
.byte CT_LOWER | CT_XDIGIT ; 97/61 _____a_____
.byte CT_LOWER | CT_XDIGIT ; 98/62 _____b_____
.byte CT_LOWER | CT_XDIGIT ; 99/63 _____c_____
.byte CT_LOWER | CT_XDIGIT ; 100/64 _____d_____
.byte CT_LOWER | CT_XDIGIT ; 101/65 _____e_____
.byte CT_LOWER | CT_XDIGIT ; 102/66 _____f_____
.byte CT_LOWER ; 103/67 _____g_____
.byte CT_LOWER ; 104/68 _____h_____
.byte CT_LOWER ; 105/69 _____i_____
.byte CT_LOWER ; 106/6a _____j_____
.byte CT_LOWER ; 107/6b _____k_____
.byte CT_LOWER ; 108/6c _____l_____
.byte CT_LOWER ; 109/6d _____m_____
.byte CT_LOWER ; 110/6e _____n_____
.byte CT_LOWER ; 111/6f _____o_____
.byte CT_LOWER ; 112/70 _____p_____
.byte CT_LOWER ; 113/71 _____q_____
.byte CT_LOWER ; 114/72 _____r_____
.byte CT_LOWER ; 115/73 _____s_____
.byte CT_LOWER ; 116/74 _____t_____
.byte CT_LOWER ; 117/75 _____u_____
.byte CT_LOWER ; 118/76 _____v_____
.byte CT_LOWER ; 119/77 _____w_____
.byte CT_LOWER ; 120/78 _____x_____
.byte CT_LOWER ; 121/79 _____y_____
.byte CT_LOWER ; 122/7a _____z_____
.byte CT_NONE ; 123/7b _____{_____
.byte CT_NONE ; 124/7c _____|_____
.byte CT_NONE ; 125/7d _____}_____
.byte CT_NONE ; 126/7e _____~_____
.byte CT_OTHER_WS ; 127/7f ____DEL____
.endrepeat

32
libsrc/gamate/cvline.s Normal file
View File

@@ -0,0 +1,32 @@
;
; 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 "gamate.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

16
libsrc/gamate/extzp.inc Normal file
View File

@@ -0,0 +1,16 @@
;
; extzp.inc for the Gamate
;
; Groepaz/Hitmen, 2015-11-19
;
; Assembler include file that imports the runtime zero page locations used
; by the Gamate runtime, ready for usage in asm code.
;
.global CURS_X: zp
.global CURS_Y: zp
.global CHARCOLOR: zp
.global RVS: zp
.global BGCOLOR: zp
.global tickcount: zp

16
libsrc/gamate/extzp.s Normal file
View File

@@ -0,0 +1,16 @@
;
; Groepaz/Hitmen, 2015-11-19
;
; zeropage locations for exclusive use by the library
;
.include "extzp.inc"
.segment "EXTZP" : zeropage
CURS_X: .res 1
CURS_Y: .res 1
CHARCOLOR: .res 1
RVS: .res 1
BGCOLOR: .res 1
tickcount: .res 4

22
libsrc/gamate/gotoxy.s Normal file
View File

@@ -0,0 +1,22 @@
;
; void gotoxy (unsigned char x, unsigned char y);
;
.export _gotoxy
.import popa, plot
.include "gamate.inc"
.include "extzp.inc"
_gotoxy:
sta CURS_Y ; Set Y
jsr popa ; Get X
sta CURS_X ; Set X
jmp plot ; Set the cursor position
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import initconio
conio_init = initconio

51
libsrc/gamate/irq.s Normal file
View File

@@ -0,0 +1,51 @@
;
; IRQ handling (Gamate version)
;
.export initirq, doneirq, IRQStub
.import __INTERRUPTOR_COUNT__, callirq_y
.include "gamate.inc"
.include "extzp.inc"
; ------------------------------------------------------------------------
.segment "INIT"
; a constructor
;
initirq:
rts
; ------------------------------------------------------------------------
.code
; a destructor
;
doneirq:
rts
; ------------------------------------------------------------------------
; 256*32 interrupts in about 1minute 60s = 136hz
; -> guess 16384 clock cycles = 135,28hz (might be audio signal 1/512?)
IRQStub:
pha
tya
pha
ldy #<(__INTERRUPTOR_COUNT__ * 2)
beq @L1
txa
pha
jsr callirq_y
pla
tax
@L1: pla
tay
pla
rts

View File

@@ -0,0 +1,95 @@
;
; Standard joystick driver for the Gamate
;
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "gamate.inc"
.macpack module
; ------------------------------------------------------------------------
; Header. Includes jump table
module_header _gamate_stdjoy_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 $01 ; JOY_UP
.byte $02 ; JOY_DOWN
.byte $04 ; JOY_LEFT
.byte $08 ; JOY_RIGHT
.byte $10 ; JOY_FIRE_A
.byte $20 ; JOY_FIRE_B
.byte $80 ; JOY_SELECT
.byte $40 ; JOY_START
; Jump table.
.addr INSTALL
.addr UNINSTALL
.addr COUNT
.addr READJOY
.addr 0 ; IRQ entry unused
; ------------------------------------------------------------------------
; Constants
JOY_COUNT = 1 ; Number of joysticks we support
.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 #>JOY_ERR_OK
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; DEINSTALL 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.
;
;unsigned char __fastcall__ joy_count (void);
COUNT:
lda #<JOY_COUNT
ldx #>JOY_COUNT
rts
; ------------------------------------------------------------------------
; READ: Read a particular joystick passed in A.
;
;unsigned char __fastcall__ joy_read (unsigned char joystick);
READJOY:
lda JOY_DATA
ldx #0
rts

View File

@@ -0,0 +1,14 @@
;
; Address of the static standard joystick driver
;
; Oliver Schmidt, 2012-11-01
;
; const void joy_static_stddrv[];
;
.export _joy_static_stddrv
.import _gamate_stdjoy_joy
.rodata
_joy_static_stddrv := _gamate_stdjoy_joy

View File

@@ -0,0 +1,13 @@
;
; Name of the standard joystick driver
;
; Oliver Schmidt, 2012-11-01
;
; const char joy_stddrv[];
;
.export _joy_stddrv
.rodata
_joy_stddrv: .asciiz "gamate-stdjoy.joy"

32
libsrc/gamate/kplot.s Normal file
View File

@@ -0,0 +1,32 @@
.export PLOT
.include "gamate.inc"
.include "extzp.inc"
PLOT:
bcs @getpos
sty LCD_X
;clc ; already cleared
lda _plotlo,x
sta LCD_Y
@getpos:
ldx CURS_Y
ldy CURS_X
rts
.export _plotlo
.rodata
_plotlo:
.repeat screenrows,line
.byte <($0000+(line*$8))
.endrepeat
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import initconio
conio_init = initconio

8
libsrc/gamate/libref.s Normal file
View File

@@ -0,0 +1,8 @@
;
; Oliver Schmidt, 2013-05-31
;
.export joy_libref
.import _exit
joy_libref := _exit

28
libsrc/gamate/revers.s Normal file
View File

@@ -0,0 +1,28 @@
.include "gamate.inc"
.include "extzp.inc"
.export _revers
.proc _revers
ldx #$00 ; Assume revers off
tay ; Test onoff
beq L1 ; Jump if off
ldx #$ff ; Load on value
ldy #$00 ; Assume old value is zero
L1: lda RVS ; Load old value
stx RVS ; Set new value
beq L2 ; Jump if old value zero
iny ; Make old value = 1
L2: ldx #$00 ; Load high byte of result
tya ; Load low byte, set CC
rts
.endproc
;-------------------------------------------------------------------------------
; force the init constructor to be imported
.import initconio
conio_init = initconio

17
libsrc/gamate/ticktock.s Normal file
View File

@@ -0,0 +1,17 @@
.interruptor ticktock, 24
.include "gamate.inc"
.include "extzp.inc"
ticktock:
; Increment the system tick counter.
inc tickcount
bne @s1
inc tickcount+1
bne @s1
inc tickcount+2
bne @s1
inc tickcount+3
@s1:
rts

228
libsrc/gamate/vga.inc Normal file
View File

@@ -0,0 +1,228 @@
; VGA charset for the PC-Engine conio implementation
.byte $00, $00, $00, $00, $00, $00, $00, $00
; 1
.byte %00000000
.byte %00000000
.byte %00000000
.byte %11111111
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
; 2
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
; 3
.byte %00010000
.byte %00010000
.byte %00010000
.byte %11111111
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
; 4
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00011111
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
; 5
.byte %00000000
.byte %00000000
.byte %00000000
.byte %11110000
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
; 6
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00011111
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
; 7
.byte %00010000
.byte %00010000
.byte %00010000
.byte %11110000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
; 8
.byte %00000000
.byte %00000000
.byte %00000000
.byte %11111111
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
; 9
.byte %00010000
.byte %00010000
.byte %00010000
.byte %11111111
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
; 10 (LF)
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
.byte %00000000
; 11
.byte %00010000
.byte %00010000
.byte %00010000
.byte %11110000
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
; 12
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00011111
.byte %00010000
.byte %00010000
.byte %00010000
.byte %00010000
.byte $3F, $33, $3F, $30, $30, $70, $F0, $E0
.byte $7F, $63, $7F, $63, $63, $67, $E6, $C0
.byte $99, $5A, $3C, $E7, $E7, $3C, $5A, $99
.byte $80, $E0, $F8, $FE, $F8, $E0, $80, $00
.byte $02, $0E, $3E, $FE, $3E, $0E, $02, $00
.byte $18, $3C, $7E, $18, $18, $7E, $3C, $18
.byte $66, $66, $66, $66, $66, $00, $66, $00
.byte $7F, $DB, $DB, $7B, $1B, $1B, $1B, $00
.byte $3E, $63, $38, $6C, $6C, $38, $CC, $78
.byte $00, $00, $00, $00, $7E, $7E, $7E, $00
.byte $18, $3C, $7E, $18, $7E, $3C, $18, $FF
.byte $18, $3C, $7E, $18, $18, $18, $18, $00
.byte $18, $18, $18, $18, $7E, $3C, $18, $00
.byte $00, $18, $0C, $FE, $0C, $18, $00, $00
.byte $00, $30, $60, $FE, $60, $30, $00, $00
.byte $00, $00, $C0, $C0, $C0, $FE, $00, $00
.byte $00, $24, $66, $FF, $66, $24, $00, $00
.byte $00, $18, $3C, $7E, $FF, $FF, $00, $00
.byte $00, $FF, $FF, $7E, $3C, $18, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $00
.byte $30, $78, $78, $78, $30, $00, $30, $00
.byte $6C, $6C, $6C, $00, $00, $00, $00, $00
.byte $6C, $6C, $FE, $6C, $FE, $6C, $6C, $00
.byte $30, $7C, $C0, $78, $0C, $F8, $30, $00
.byte $00, $C6, $CC, $18, $30, $66, $C6, $00
.byte $38, $6C, $38, $76, $DC, $CC, $76, $00
.byte $60, $60, $C0, $00, $00, $00, $00, $00
.byte $18, $30, $60, $60, $60, $30, $18, $00
.byte $60, $30, $18, $18, $18, $30, $60, $00
.byte $00, $66, $3C, $FF, $3C, $66, $00, $00
.byte $00, $30, $30, $FC, $30, $30, $00, $00
.byte $00, $00, $00, $00, $00, $30, $30, $60
.byte $00, $00, $00, $FC, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $30, $30, $00
.byte $06, $0C, $18, $30, $60, $C0, $80, $00
.byte $7C, $C6, $CE, $DE, $F6, $E6, $7C, $00
.byte $30, $70, $30, $30, $30, $30, $FC, $00
.byte $78, $CC, $0C, $38, $60, $CC, $FC, $00
.byte $78, $CC, $0C, $38, $0C, $CC, $78, $00
.byte $1C, $3C, $6C, $CC, $FE, $0C, $1E, $00
.byte $FC, $C0, $F8, $0C, $0C, $CC, $78, $00
.byte $38, $60, $C0, $F8, $CC, $CC, $78, $00
.byte $FC, $CC, $0C, $18, $30, $30, $30, $00
.byte $78, $CC, $CC, $78, $CC, $CC, $78, $00
.byte $78, $CC, $CC, $7C, $0C, $18, $70, $00
.byte $00, $30, $30, $00, $00, $30, $30, $00
.byte $00, $30, $30, $00, $00, $30, $30, $60
.byte $18, $30, $60, $C0, $60, $30, $18, $00
.byte $00, $00, $FC, $00, $00, $FC, $00, $00
.byte $60, $30, $18, $0C, $18, $30, $60, $00
.byte $78, $CC, $0C, $18, $30, $00, $30, $00
.byte $7C, $C6, $DE, $DE, $DE, $C0, $78, $00
.byte $30, $78, $CC, $CC, $FC, $CC, $CC, $00
.byte $FC, $66, $66, $7C, $66, $66, $FC, $00
.byte $3C, $66, $C0, $C0, $C0, $66, $3C, $00
.byte $F8, $6C, $66, $66, $66, $6C, $F8, $00
.byte $7E, $60, $60, $78, $60, $60, $7E, $00
.byte $7E, $60, $60, $78, $60, $60, $60, $00
.byte $3C, $66, $C0, $C0, $CE, $66, $3E, $00
.byte $CC, $CC, $CC, $FC, $CC, $CC, $CC, $00
.byte $78, $30, $30, $30, $30, $30, $78, $00
.byte $1E, $0C, $0C, $0C, $CC, $CC, $78, $00
.byte $E6, $66, $6C, $78, $6C, $66, $E6, $00
.byte $60, $60, $60, $60, $60, $60, $7E, $00
.byte $C6, $EE, $FE, $FE, $D6, $C6, $C6, $00
.byte $C6, $E6, $F6, $DE, $CE, $C6, $C6, $00
.byte $38, $6C, $C6, $C6, $C6, $6C, $38, $00
.byte $FC, $66, $66, $7C, $60, $60, $F0, $00
.byte $78, $CC, $CC, $CC, $DC, $78, $1C, $00
.byte $FC, $66, $66, $7C, $6C, $66, $E6, $00
.byte $78, $CC, $E0, $70, $1C, $CC, $78, $00
.byte $FC, $30, $30, $30, $30, $30, $30, $00
.byte $CC, $CC, $CC, $CC, $CC, $CC, $FC, $00
.byte $CC, $CC, $CC, $CC, $CC, $78, $30, $00
.byte $C6, $C6, $C6, $D6, $FE, $EE, $C6, $00
.byte $C6, $C6, $6C, $38, $38, $6C, $C6, $00
.byte $CC, $CC, $CC, $78, $30, $30, $78, $00
.byte $FE, $06, $0C, $18, $30, $60, $FE, $00
.byte $78, $60, $60, $60, $60, $60, $78, $00
.byte $C0, $60, $30, $18, $0C, $06, $02, $00
.byte $78, $18, $18, $18, $18, $18, $78, $00
.byte $10, $38, $6C, $C6, $00, $00, $00, $00
.byte $00, $00, $00, $00, $00, $00, $00, $FF
.byte $30, $30, $18, $00, $00, $00, $00, $00
.byte $00, $00, $78, $0C, $7C, $CC, $76, $00
.byte $E0, $60, $60, $7C, $66, $66, $DC, $00
.byte $00, $00, $78, $CC, $C0, $CC, $78, $00
.byte $1C, $0C, $0C, $7C, $CC, $CC, $76, $00
.byte $00, $00, $78, $CC, $FC, $C0, $78, $00
.byte $38, $6C, $60, $F0, $60, $60, $F0, $00
.byte $00, $00, $76, $CC, $CC, $7C, $0C, $F8
.byte $E0, $60, $6C, $76, $66, $66, $E6, $00
.byte $30, $00, $70, $30, $30, $30, $78, $00
.byte $0C, $00, $0C, $0C, $0C, $CC, $CC, $78
.byte $E0, $60, $66, $6C, $78, $6C, $E6, $00
.byte $70, $30, $30, $30, $30, $30, $78, $00
.byte $00, $00, $CC, $FE, $FE, $D6, $C6, $00
.byte $00, $00, $F8, $CC, $CC, $CC, $CC, $00
.byte $00, $00, $78, $CC, $CC, $CC, $78, $00
.byte $00, $00, $DC, $66, $66, $7C, $60, $F0
.byte $00, $00, $76, $CC, $CC, $7C, $0C, $1E
.byte $00, $00, $DC, $76, $66, $60, $F0, $00
.byte $00, $00, $7C, $C0, $78, $0C, $F8, $00
.byte $10, $30, $7C, $30, $30, $34, $18, $00
.byte $00, $00, $CC, $CC, $CC, $CC, $76, $00
.byte $00, $00, $CC, $CC, $CC, $78, $30, $00
.byte $00, $00, $C6, $D6, $FE, $FE, $6C, $00
.byte $00, $00, $C6, $6C, $38, $6C, $C6, $00
.byte $00, $00, $CC, $CC, $CC, $7C, $0C, $F8
.byte $00, $00, $FC, $98, $30, $64, $FC, $00
.byte $1C, $30, $30, $E0, $30, $30, $1C, $00
.byte $18, $18, $18, $00, $18, $18, $18, $00
.byte $E0, $30, $30, $1C, $30, $30, $E0, $00
.byte $76, $DC, $00, $00, $00, $00, $00, $00
.byte $00, $10, $38, $6C, $C6, $C6, $FE, $00

View File

@@ -0,0 +1,20 @@
;
; void waitvblank (void);
;
.include "gamate.inc"
.include "extzp.inc"
.forceimport ticktock
.export _waitvblank
; FIXME: is this actually correct?
.proc _waitvblank
lda tickcount
@lp: cmp tickcount
beq @lp
rts
.endproc

20
libsrc/gamate/wherex.s Normal file
View File

@@ -0,0 +1,20 @@
;
; Ullrich von Bassewitz, 2003-05-02
;
; unsigned char wherex (void);
;
.export _wherex
.include "gamate.inc"
.include "extzp.inc"
.proc _wherex
lda CURS_X
ldx #$00
rts
.endproc

20
libsrc/gamate/wherey.s Normal file
View File

@@ -0,0 +1,20 @@
;
; Ullrich von Bassewitz, 2003-05-02
;
; unsigned char wherey (void);
;
.export _wherey
.include "gamate.inc"
.include "extzp.inc"
.proc _wherey
lda CURS_Y
ldx #$00
rts
.endproc