more cleanup, joystick works again
This commit is contained in:
@@ -1,12 +1,17 @@
|
|||||||
|
;
|
||||||
|
; PCE definitions. By Groepaz/Hitmem.
|
||||||
|
;
|
||||||
|
|
||||||
; Write VDC register
|
;; FIXME: optimize zeropage usage
|
||||||
.macro VREG arg1,arg2
|
|
||||||
st0 #arg1
|
|
||||||
st1 #<(arg2)
|
|
||||||
st2 #>(arg2)
|
|
||||||
.endmacro
|
|
||||||
|
|
||||||
_tickcount= $20
|
CURS_X = $30
|
||||||
|
CURS_Y = $31
|
||||||
|
SCREEN_PTR = $32 ;2
|
||||||
|
CRAM_PTR = $34 ;2
|
||||||
|
CHARCOLOR = $36
|
||||||
|
RVS = $37
|
||||||
|
BGCOLOR = $38
|
||||||
|
_tickcount = $39 ;2
|
||||||
|
|
||||||
screenrows = (224/8)
|
screenrows = (224/8)
|
||||||
charsperline = (512/8)
|
charsperline = (512/8)
|
||||||
@@ -15,14 +20,6 @@ xsize = charsperline
|
|||||||
CH_HLINE = 7
|
CH_HLINE = 7
|
||||||
CH_VLINE = 7
|
CH_VLINE = 7
|
||||||
|
|
||||||
CURS_X = $30
|
|
||||||
CURS_Y = $31
|
|
||||||
SCREEN_PTR = $32
|
|
||||||
CRAM_PTR = $34
|
|
||||||
CHARCOLOR = $36
|
|
||||||
RVS = $37
|
|
||||||
BGCOLOR=$38
|
|
||||||
|
|
||||||
; huc6270 - Video Display Controller (vdc)
|
; huc6270 - Video Display Controller (vdc)
|
||||||
|
|
||||||
VDC_MAWR = 0 ; Memory Address Write Register
|
VDC_MAWR = 0 ; Memory Address Write Register
|
||||||
@@ -45,9 +42,9 @@ VDC_DESR =16 ; (DMA) Destination Register
|
|||||||
VDC_LENR =17 ; (DMA) Length Register
|
VDC_LENR =17 ; (DMA) Length Register
|
||||||
VDC_SATB =18 ; Sprite Attribute Table
|
VDC_SATB =18 ; Sprite Attribute Table
|
||||||
|
|
||||||
VDC_CTRL = $0000
|
VDC_CTRL = $0000
|
||||||
VDC_DATA_LO = $0002
|
VDC_DATA_LO = $0002
|
||||||
VDC_DATA_HI = $0003
|
VDC_DATA_HI = $0003
|
||||||
|
|
||||||
; huc6260 - Video Color Encoder (vce)
|
; huc6260 - Video Color Encoder (vce)
|
||||||
|
|
||||||
@@ -61,18 +58,17 @@ VCE_ADDR_HI = $0403 ; MSB of byte offset into palette
|
|||||||
VCE_DATA_LO = $0404 ; LSB of 16-bit palette data
|
VCE_DATA_LO = $0404 ; LSB of 16-bit palette data
|
||||||
VCE_DATA_HI = $0405 ; MSB of 16-bit palette data
|
VCE_DATA_HI = $0405 ; MSB of 16-bit palette data
|
||||||
|
|
||||||
TIMER_COUNT = $0c00
|
TIMER_COUNT = $0c00
|
||||||
TIMER_CTRL = $0c01
|
TIMER_CTRL = $0c01
|
||||||
|
|
||||||
JOY_CTRL = $1000
|
JOY_CTRL = $1000
|
||||||
|
|
||||||
IRQ_MASK = $1402
|
IRQ_MASK = $1402
|
||||||
IRQ_STATUS = $1403
|
IRQ_STATUS = $1403
|
||||||
|
|
||||||
CDR_MEM_DISABLE = $1803
|
CDR_MEM_DISABLE = $1803
|
||||||
CDR_MEM_ENABLE = $1807
|
CDR_MEM_ENABLE = $1807
|
||||||
|
|
||||||
|
|
||||||
;; lda abs
|
;; lda abs
|
||||||
.macro ldaio arg1
|
.macro ldaio arg1
|
||||||
.byte $ad
|
.byte $ad
|
||||||
@@ -88,3 +84,10 @@ CDR_MEM_ENABLE = $1807
|
|||||||
.byte $9c
|
.byte $9c
|
||||||
.word arg1
|
.word arg1
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
; Write VDC register
|
||||||
|
.macro VREG arg1,arg2
|
||||||
|
st0 #arg1
|
||||||
|
st1 #<(arg2)
|
||||||
|
st2 #>(arg2)
|
||||||
|
.endmacro
|
||||||
70
cfg/pce.cfg
70
cfg/pce.cfg
@@ -1,62 +1,32 @@
|
|||||||
|
# linker config to produce simple NEC PC-Engine cartridge (.pce)
|
||||||
|
|
||||||
SYMBOLS {
|
SYMBOLS {
|
||||||
__STACKSIZE__: type = weak, value = $0300; # 3 pages stack
|
__STACKSIZE__: type = weak, value = $0300; # 3 pages stack
|
||||||
}
|
}
|
||||||
|
|
||||||
MEMORY {
|
MEMORY {
|
||||||
|
# FIXME: is this correct? the first 3? bytes cant be used?
|
||||||
|
ZP: start = $03, size = $1A, type = rw, define = yes;
|
||||||
|
|
||||||
ZP: start = $00, size = $1A, type = rw, define = yes;
|
# reset-bank and hardware vectors
|
||||||
|
ROM0: start = $e000, size = $1ff6, file = %O ,fill = yes, define = yes;
|
||||||
# INES Cartridge Header
|
ROMV: start = $fff6, size = $a, file = %O,fill = yes;
|
||||||
#HEADER: start = $0, size = $10, file = %O ,fill = yes;
|
|
||||||
|
|
||||||
# 2 16K ROM Banks
|
|
||||||
# - startup
|
|
||||||
# - code
|
|
||||||
# - rodata
|
|
||||||
# - data (load)
|
|
||||||
# 1 8k CHR Bank
|
|
||||||
ROM0: start = $e000, size = $1ff6, file = %O ,fill = yes, define = yes;
|
|
||||||
# Hardware Vectors at End of 2nd 8K ROM
|
|
||||||
ROMV: start = $fff6, size = $a, file = %O,fill = yes;
|
|
||||||
|
|
||||||
# ROM: start = $6000, size = $8000, file = %O, fill = yes,define=yes;
|
|
||||||
|
|
||||||
|
|
||||||
# standard 2k SRAM (-zeropage)
|
|
||||||
# $0100-$0200 cpu stack
|
|
||||||
# $0200-$0500 3 pages for ppu memory write buffer
|
|
||||||
# $0500-$0800 3 pages for cc65 parameter stack
|
|
||||||
#SRAM: start = $0500, size = $0300, define = yes;
|
|
||||||
|
|
||||||
# additional 8K SRAM Bank
|
|
||||||
# - data (run)
|
|
||||||
# - bss
|
|
||||||
# - heap
|
|
||||||
# RAM: start = $2200, size = $1000, define = yes;
|
|
||||||
# RAM2: start = $3200, size = $0e00, define = yes;
|
|
||||||
RAM: start = $2200, size = $1e00, define = yes;
|
|
||||||
|
|
||||||
|
# first RAM page (also contains stack and zeropage)
|
||||||
|
RAM: start = $2200, size = $1e00, define = yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEGMENTS {
|
SEGMENTS {
|
||||||
#HEADER: load = HEADER, type = wprot;
|
STARTUP: load = ROM0, type = ro, define = yes;
|
||||||
|
INIT: load = ROM0, type = ro, define = yes, optional = yes;
|
||||||
#aSTARTUP: load = ROM0, type = wprot, define = yes;
|
CODE: load = ROM0, type = ro, define = yes;
|
||||||
STARTUP: load = ROM0, type = ro, define = yes;
|
RODATA: load = ROM0, type = ro, define = yes;
|
||||||
|
DATA: load = ROM0, run= RAM, type = rw, define = yes;
|
||||||
INIT: load = ROM0, type = ro, define = yes, optional = yes;
|
BSS: load = RAM, type = bss, define = yes;
|
||||||
CODE: load = ROM0, type = ro, define = yes;
|
VECTORS: load = ROMV, type = rw, define = yes;
|
||||||
RODATA: load = ROM0, type = ro, define = yes;
|
ZEROPAGE: load = ZP, type = zp, define = yes;
|
||||||
|
|
||||||
DATA: load = ROM0, run= RAM, type = rw, define = yes;
|
|
||||||
# BSS: load = RAM2, type = bss, define = yes;
|
|
||||||
BSS: load = RAM, type = bss, define = yes;
|
|
||||||
|
|
||||||
VECTORS: load = ROMV, type = rw, define = yes;
|
|
||||||
#CHARS: load = ROM2, type = rw;
|
|
||||||
|
|
||||||
|
|
||||||
ZEROPAGE: load = ZP, type = zp, define = yes;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FEATURES {
|
FEATURES {
|
||||||
CONDES: segment = STARTUP,
|
CONDES: segment = STARTUP,
|
||||||
type=constructor,
|
type=constructor,
|
||||||
|
|||||||
155
include/pce.h
155
include/pce.h
@@ -1,74 +1,99 @@
|
|||||||
#define CH_CROSS 0x10
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
#define CH_RTEE 0x17
|
/* pce.h */
|
||||||
#define CH_LTEE 0x0f
|
/* */
|
||||||
|
/* PC-Engine system specific definitions */
|
||||||
#define CH_ULCORNER 0x10
|
/* */
|
||||||
#define CH_URCORNER 0x10
|
/* */
|
||||||
#define CH_LLCORNER 0x10
|
/* */
|
||||||
#define CH_LRCORNER 0x10
|
/* (C) 2015 Groepaz/Hitmen */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* 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. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#define TV_NTSC 0
|
|
||||||
#define TV_PAL 1
|
|
||||||
#define get_tv() 0
|
|
||||||
|
|
||||||
#define CLOCKS_PER_SEC 50 // ???
|
#ifndef _PCE_H
|
||||||
#define CLK_TCK 50 // ?!?
|
#define _PCE_H
|
||||||
|
|
||||||
//#ifndef CH_ENTER
|
|
||||||
#define CH_ENTER '\n'
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#define CH_STOP 0x08
|
|
||||||
|
|
||||||
#define CH_F1 0x14
|
/* Check for errors */
|
||||||
#define CH_F3 0x15
|
#if !defined(__PCE__)
|
||||||
#define CH_F5 0x16
|
# error This module may only be used when compiling for the PCE!
|
||||||
#define CH_F7 0x17
|
|
||||||
|
|
||||||
#define CH_CURS_UP 0x01
|
|
||||||
#define CH_CURS_DOWN 0x02
|
|
||||||
|
|
||||||
#ifndef CH_CURS_LEFT
|
|
||||||
#define CH_CURS_LEFT 0x03
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CH_CURS_RIGHT
|
/* FIXME: the respective characters are not present in the VGA charset (yet) */
|
||||||
#define CH_CURS_RIGHT 0x04
|
#define CH_CROSS 0x10
|
||||||
|
|
||||||
|
#define CH_RTEE 0x17
|
||||||
|
#define CH_LTEE 0x0f
|
||||||
|
|
||||||
|
#define CH_ULCORNER 0x10
|
||||||
|
#define CH_URCORNER 0x10
|
||||||
|
#define CH_LLCORNER 0x10
|
||||||
|
#define CH_LRCORNER 0x10
|
||||||
|
|
||||||
|
/* Color defines (CBM compatible, for conio) */
|
||||||
|
#define COLOR_BLACK 0x00
|
||||||
|
#define COLOR_WHITE 0x01
|
||||||
|
#define COLOR_RED 0x02
|
||||||
|
#define COLOR_CYAN 0x03
|
||||||
|
#define COLOR_VIOLET 0x04
|
||||||
|
#define COLOR_GREEN 0x05
|
||||||
|
#define COLOR_BLUE 0x06
|
||||||
|
#define COLOR_YELLOW 0x07
|
||||||
|
#define COLOR_ORANGE 0x08
|
||||||
|
#define COLOR_BROWN 0x09
|
||||||
|
#define COLOR_LIGHTRED 0x0A
|
||||||
|
#define COLOR_GRAY1 0x0B
|
||||||
|
#define COLOR_GRAY2 0x0C
|
||||||
|
#define COLOR_LIGHTGREEN 0x0D
|
||||||
|
#define COLOR_LIGHTBLUE 0x0E
|
||||||
|
#define COLOR_GRAY3 0x0F
|
||||||
|
|
||||||
|
#define CLOCKS_PER_SEC 50 // ???
|
||||||
|
#define CLK_TCK 50 // ?!?
|
||||||
|
|
||||||
|
#define TV_NTSC 0
|
||||||
|
#define TV_PAL 1
|
||||||
|
#define TV_OTHER 2
|
||||||
|
|
||||||
|
/* No support for dynamically loadable drivers */
|
||||||
|
#define DYN_DRV 0
|
||||||
|
|
||||||
|
/* The addresses of the static drivers */
|
||||||
|
extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
|
||||||
|
|
||||||
|
#define JOY_FIRE_B 5
|
||||||
|
#define JOY_START 6
|
||||||
|
#define JOY_SELECT 7
|
||||||
|
|
||||||
|
/* FIXME: not implemented */
|
||||||
|
void waitvblank (void);
|
||||||
|
/* Wait for the vertical blanking */
|
||||||
|
|
||||||
|
/* FIXME: not implemented */
|
||||||
|
unsigned char get_tv (void);
|
||||||
|
/* Return the video mode the machine is using. */
|
||||||
|
|
||||||
|
|
||||||
|
/* End of pce.h */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CH_ESC 8
|
|
||||||
|
|
||||||
#define CH_DEL 20
|
|
||||||
|
|
||||||
/* Color defines */
|
|
||||||
#define COLOR_BLACK 0x00
|
|
||||||
#define COLOR_WHITE 0x01
|
|
||||||
#define COLOR_RED 0x02
|
|
||||||
#define COLOR_CYAN 0x03
|
|
||||||
#define COLOR_VIOLET 0x04
|
|
||||||
#define COLOR_GREEN 0x05
|
|
||||||
#define COLOR_BLUE 0x06
|
|
||||||
#define COLOR_YELLOW 0x07
|
|
||||||
#define COLOR_ORANGE 0x08
|
|
||||||
#define COLOR_BROWN 0x09
|
|
||||||
#define COLOR_LIGHTRED 0x0A
|
|
||||||
#define COLOR_GRAY1 0x0B
|
|
||||||
#define COLOR_GRAY2 0x0C
|
|
||||||
#define COLOR_LIGHTGREEN 0x0D
|
|
||||||
#define COLOR_LIGHTBLUE 0x0E
|
|
||||||
#define COLOR_GRAY3 0x0F
|
|
||||||
|
|
||||||
#define JOY_FIRE_B 5
|
|
||||||
#define JOY_START 6
|
|
||||||
#define JOY_SELECT 7
|
|
||||||
|
|
||||||
/*
|
|
||||||
void __fastcall__ waitvblank(void);
|
|
||||||
|
|
||||||
unsigned char __fastcall__ cpeekcharxy(unsigned char x,unsigned char y);
|
|
||||||
unsigned char __fastcall__ cpeekchar(void);
|
|
||||||
unsigned char __fastcall__ cpeekcolxy(unsigned char x,unsigned char y);
|
|
||||||
unsigned char __fastcall__ cpeekcol(void);
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 06.08.1998
|
|
||||||
;
|
|
||||||
; CC65 runtime: call function via pointer in ax
|
; CC65 runtime: call function via pointer in ax
|
||||||
;
|
;
|
||||||
|
|
||||||
.export callax
|
.export callax
|
||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
callax:
|
callax:
|
||||||
sta vec
|
sta vec
|
||||||
stx vec+1
|
stx vec+1
|
||||||
jmp (vec) ; jump there
|
jmp (vec) ; jump there
|
||||||
|
|
||||||
.bss
|
.bss
|
||||||
|
|
||||||
vec:
|
vec:
|
||||||
.res 2
|
.res 2
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 21.09.1998
|
|
||||||
;
|
|
||||||
; clock_t clock (void);
|
; clock_t clock (void);
|
||||||
;
|
;
|
||||||
|
|
||||||
.include "pcengine.inc"
|
.include "pce.inc"
|
||||||
|
|
||||||
.export _clock
|
.export _clock
|
||||||
.importzp sreg
|
.importzp sreg
|
||||||
|
|
||||||
.proc _clock
|
|
||||||
|
|
||||||
ldy #0 ; Byte 3 is always zero
|
.proc _clock
|
||||||
|
|
||||||
|
ldy #0 ; Byte 3 is always zero
|
||||||
sty sreg+1
|
sty sreg+1
|
||||||
sty sreg
|
sty sreg
|
||||||
|
|
||||||
@@ -20,4 +18,3 @@
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
.include "pcengine.inc"
|
.include "pce.inc"
|
||||||
|
|
||||||
.export _clrscr
|
.export _clrscr
|
||||||
_clrscr:
|
_clrscr:
|
||||||
|
|||||||
@@ -1,59 +1,57 @@
|
|||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 06.08.1998
|
|
||||||
;
|
|
||||||
; unsigned char __fastcall__ textcolor (unsigned char color);
|
; unsigned char __fastcall__ textcolor (unsigned char color);
|
||||||
; unsigned char __fastcall__ bgcolor (unsigned char color);
|
; unsigned char __fastcall__ bgcolor (unsigned char color);
|
||||||
; unsigned char __fastcall__ bordercolor (unsigned char color);
|
; unsigned char __fastcall__ bordercolor (unsigned char color);
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
.export _textcolor, _bgcolor, _bordercolor
|
.export _textcolor, _bgcolor, _bordercolor
|
||||||
|
|
||||||
.include "pcengine.inc"
|
.include "pce.inc"
|
||||||
|
|
||||||
_textcolor:
|
_textcolor:
|
||||||
ldx CHARCOLOR ; get old value
|
ldx CHARCOLOR ; get old value
|
||||||
sta CHARCOLOR ; set new value
|
sta CHARCOLOR ; set new value
|
||||||
txa
|
txa
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_bgcolor:
|
_bgcolor:
|
||||||
ldx BGCOLOR ; get old value
|
ldx BGCOLOR ; get old value
|
||||||
sta BGCOLOR ; set new value
|
sta BGCOLOR ; set new value
|
||||||
asl a
|
asl a
|
||||||
tay
|
tay
|
||||||
|
|
||||||
stz VCE_ADDR_LO
|
stz VCE_ADDR_LO
|
||||||
stz VCE_ADDR_HI
|
stz VCE_ADDR_HI
|
||||||
lda colors,y
|
lda colors,y
|
||||||
sta VCE_DATA_LO
|
sta VCE_DATA_LO
|
||||||
lda colors+1,y
|
lda colors+1,y
|
||||||
sta VCE_DATA_HI
|
sta VCE_DATA_HI
|
||||||
|
|
||||||
txa
|
txa
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_bordercolor:
|
_bordercolor:
|
||||||
lda #0
|
lda #0
|
||||||
txa
|
txa
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.export colors
|
.export colors
|
||||||
|
|
||||||
colors: ; G R B
|
colors: ; G R B
|
||||||
.word ((0<<6)+(0<<3)+(0)) ; 0 black
|
.word ((0<<6)+(0<<3)+(0)) ; 0 black
|
||||||
.word ((7<<6)+(7<<3)+(7)) ; 1 white
|
.word ((7<<6)+(7<<3)+(7)) ; 1 white
|
||||||
.word ((0<<6)+(7<<3)+(0)) ; 2 red
|
.word ((0<<6)+(7<<3)+(0)) ; 2 red
|
||||||
.word ((7<<6)+(0<<3)+(7)) ; 3 cyan
|
.word ((7<<6)+(0<<3)+(7)) ; 3 cyan
|
||||||
.word ((0<<6)+(5<<3)+(7)) ; 4 violett
|
.word ((0<<6)+(5<<3)+(7)) ; 4 violett
|
||||||
.word ((7<<6)+(0<<3)+(0)) ; 5 green
|
.word ((7<<6)+(0<<3)+(0)) ; 5 green
|
||||||
.word ((0<<6)+(0<<3)+(7)) ; 6 blue
|
.word ((0<<6)+(0<<3)+(7)) ; 6 blue
|
||||||
.word ((7<<6)+(7<<3)+(0)) ; 7 yellow
|
.word ((7<<6)+(7<<3)+(0)) ; 7 yellow
|
||||||
.word ((5<<6)+(7<<3)+(0)) ; 8 orange
|
.word ((5<<6)+(7<<3)+(0)) ; 8 orange
|
||||||
.word ((3<<6)+(4<<3)+(3)) ; 9 brown
|
.word ((3<<6)+(4<<3)+(3)) ; 9 brown
|
||||||
.word ((4<<6)+(7<<3)+(4)) ; a light red
|
.word ((4<<6)+(7<<3)+(4)) ; a light red
|
||||||
.word ((3<<6)+(3<<3)+(3)) ; b dark grey
|
.word ((3<<6)+(3<<3)+(3)) ; b dark grey
|
||||||
.word ((4<<6)+(4<<3)+(4)) ; c middle grey
|
.word ((4<<6)+(4<<3)+(4)) ; c middle grey
|
||||||
.word ((7<<6)+(4<<3)+(4)) ; d light green
|
.word ((7<<6)+(4<<3)+(4)) ; d light green
|
||||||
.word ((4<<6)+(4<<3)+(7)) ; e light blue
|
.word ((4<<6)+(4<<3)+(7)) ; e light blue
|
||||||
.word ((6<<6)+(6<<3)+(6)) ; f light gray
|
.word ((6<<6)+(6<<3)+(6)) ; f light gray
|
||||||
|
|||||||
@@ -94,9 +94,3 @@ getbyt:
|
|||||||
;;getbyt_:
|
;;getbyt_:
|
||||||
lda $FFFF,y
|
lda $FFFF,y
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;; callax doesnt work? why?!
|
|
||||||
;_callax:
|
|
||||||
; sta @l+1
|
|
||||||
; stx @l+2
|
|
||||||
;@l: jmp $dead
|
|
||||||
|
|||||||
@@ -1,122 +1,105 @@
|
|||||||
.include "pcengine.inc"
|
.include "pce.inc"
|
||||||
.import vce_init
|
|
||||||
.import psg_init
|
|
||||||
.import vdc_init
|
|
||||||
|
|
||||||
.export initconio
|
.import vce_init
|
||||||
.export _conio_init
|
.import psg_init
|
||||||
|
.import vdc_init
|
||||||
|
|
||||||
.constructor initconio, 24
|
.export initconio
|
||||||
|
.export _conio_init
|
||||||
|
|
||||||
.macpack longbranch
|
.constructor initconio, 24
|
||||||
|
|
||||||
|
.macpack longbranch
|
||||||
initconio:
|
initconio:
|
||||||
;; jsr vdc_init
|
;; jsr vdc_init
|
||||||
jsr vce_init
|
jsr vce_init
|
||||||
jsr psg_init
|
jsr psg_init
|
||||||
jsr conio_init
|
jsr conio_init
|
||||||
jsr set_palette
|
jsr set_palette
|
||||||
|
|
||||||
st0 #VDC_RCR
|
st0 #VDC_RCR
|
||||||
st1 #<$0088
|
st1 #<$0088
|
||||||
st2 #>$0088
|
st2 #>$0088
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.import colors
|
.import colors
|
||||||
set_palette:
|
set_palette:
|
||||||
|
stz VCE_ADDR_LO
|
||||||
|
stz VCE_ADDR_HI
|
||||||
|
|
||||||
; Make palette (use VGA palette?)
|
ldx #0
|
||||||
; stz VCE_ADDR_LO
|
|
||||||
; stz VCE_ADDR_HI
|
|
||||||
; clx
|
|
||||||
; cly
|
|
||||||
vce_loop: ;; stx VCE_DATA_LO
|
|
||||||
;; sty VCE_DATA_HI
|
|
||||||
; inx
|
|
||||||
; cpx #$00
|
|
||||||
; bne vce_loop
|
|
||||||
; iny
|
|
||||||
; cpy #$02
|
|
||||||
; bne vce_loop
|
|
||||||
|
|
||||||
|
|
||||||
stz VCE_ADDR_LO
|
|
||||||
stz VCE_ADDR_HI
|
|
||||||
|
|
||||||
ldx #0
|
|
||||||
@lp:
|
@lp:
|
||||||
.repeat 16
|
.repeat 16
|
||||||
lda colors,x
|
lda colors,x
|
||||||
sta VCE_DATA_LO
|
sta VCE_DATA_LO
|
||||||
lda colors+1,x
|
lda colors+1,x
|
||||||
sta VCE_DATA_HI
|
sta VCE_DATA_HI
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
inx
|
inx
|
||||||
inx
|
inx
|
||||||
cpx #16*2;*5
|
cpx #16*2
|
||||||
jne @lp
|
jne @lp
|
||||||
|
|
||||||
stz VCE_ADDR_LO
|
stz VCE_ADDR_LO
|
||||||
stz VCE_ADDR_HI
|
stz VCE_ADDR_HI
|
||||||
stz VCE_DATA_LO
|
stz VCE_DATA_LO
|
||||||
stz VCE_DATA_HI
|
stz VCE_DATA_HI
|
||||||
|
|
||||||
; so it will get linked in
|
; so it will get linked in
|
||||||
_conio_init:
|
_conio_init:
|
||||||
rts
|
rts
|
||||||
|
|
||||||
;----------------------------------------------------------------------------
|
;----------------------------------------------------------------------------
|
||||||
;
|
;
|
||||||
;----------------------------------------------------------------------------
|
;----------------------------------------------------------------------------
|
||||||
|
|
||||||
.importzp ptr1
|
.importzp ptr1
|
||||||
|
|
||||||
conio_init:
|
conio_init:
|
||||||
|
; Load font
|
||||||
|
st0 #VDC_MAWR
|
||||||
|
st1 #<$2000
|
||||||
|
st2 #>$2000
|
||||||
|
|
||||||
; Load font
|
; ptr to font data
|
||||||
st0 #VDC_MAWR
|
lda #<font
|
||||||
st1 #<$2000
|
sta ptr1
|
||||||
st2 #>$2000
|
lda #>font
|
||||||
|
sta ptr1+1
|
||||||
|
|
||||||
; ptr to font data
|
st0 #VDC_VWR ; VWR
|
||||||
lda #<font
|
ldy #$80 ; 128 chars
|
||||||
sta ptr1
|
charloop: ldx #$08 ; 8 bytes/char
|
||||||
lda #>font
|
lineloop:
|
||||||
sta ptr1+1
|
lda (ptr1)
|
||||||
|
staio VDC_DATA_LO ; bitplane 0
|
||||||
|
stzio VDC_DATA_HI ; bitplane 1
|
||||||
|
|
||||||
st0 #VDC_VWR ; VWR
|
clc ; increment font pointer
|
||||||
ldy #$80 ; 128 chars
|
lda ptr1
|
||||||
charloop: ldx #$08 ; 8 bytes/char
|
adc #$01
|
||||||
lineloop:
|
sta ptr1
|
||||||
;;lda [$00] ; read font byte
|
lda ptr1+1
|
||||||
lda (ptr1)
|
adc #$00
|
||||||
staio VDC_DATA_LO ; bitplane 0
|
sta ptr1+1
|
||||||
stzio VDC_DATA_HI ; bitplane 1
|
dex
|
||||||
|
bne lineloop ; next bitplane 0 byte
|
||||||
|
ldx #$08 ; fill bitplane 2/3 with 0
|
||||||
|
fillloop: st1 #$00
|
||||||
|
st2 #$00
|
||||||
|
dex
|
||||||
|
bne fillloop ; next byte
|
||||||
|
dey
|
||||||
|
bne charloop ; next character
|
||||||
|
|
||||||
clc ; increment font pointer
|
ldx #0
|
||||||
lda ptr1
|
stx BGCOLOR
|
||||||
adc #$01
|
inx
|
||||||
sta ptr1
|
stx CHARCOLOR
|
||||||
lda ptr1+1
|
|
||||||
adc #$00
|
|
||||||
sta ptr1+1
|
|
||||||
dex
|
|
||||||
bne lineloop ; next bitplane 0 byte
|
|
||||||
ldx #$08 ; fill bitplane 2/3 with 0
|
|
||||||
fillloop: st1 #$00
|
|
||||||
st2 #$00
|
|
||||||
dex
|
|
||||||
bne fillloop ; next byte
|
|
||||||
dey
|
|
||||||
bne charloop ; next character
|
|
||||||
|
|
||||||
ldx #0
|
|
||||||
stx BGCOLOR
|
|
||||||
inx
|
|
||||||
stx CHARCOLOR
|
|
||||||
|
|
||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
.rodata
|
.rodata
|
||||||
font: .include "vga.inc"
|
font:
|
||||||
|
.include "vga.inc"
|
||||||
|
|||||||
@@ -1,81 +1,59 @@
|
|||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 06.08.1998
|
|
||||||
;
|
|
||||||
; void cputcxy (unsigned char x, unsigned char y, char c);
|
; void cputcxy (unsigned char x, unsigned char y, char c);
|
||||||
; void cputc (char c);
|
; void cputc (char c);
|
||||||
;
|
;
|
||||||
|
|
||||||
.export _cputcxy, _cputc, cputdirect, putchar
|
.export _cputcxy, _cputc, cputdirect, putchar
|
||||||
.export newline, plot
|
.export newline, plot
|
||||||
.import popa, _gotoxy
|
.import popa, _gotoxy
|
||||||
.import PLOT
|
.import PLOT
|
||||||
|
|
||||||
.importzp tmp3,tmp4
|
|
||||||
|
|
||||||
.include "pcengine.inc"
|
|
||||||
|
|
||||||
|
.importzp tmp3,tmp4
|
||||||
|
|
||||||
|
.include "pce.inc"
|
||||||
_cputcxy:
|
_cputcxy:
|
||||||
pha ; Save C
|
pha ; Save C
|
||||||
jsr popa ; Get Y
|
jsr popa ; Get Y
|
||||||
jsr _gotoxy ; Set cursor, drop x
|
jsr _gotoxy ; Set cursor, drop x
|
||||||
pla ; Restore C
|
pla ; Restore C
|
||||||
|
|
||||||
; Plot a character - also used as internal function
|
; Plot a character - also used as internal function
|
||||||
|
|
||||||
_cputc: cmp #$0d ; CR?
|
_cputc: cmp #$0d ; CR?
|
||||||
bne L1
|
bne L1
|
||||||
lda #0
|
lda #0
|
||||||
sta CURS_X
|
sta CURS_X
|
||||||
beq plot ; Recalculate pointers
|
beq plot ; Recalculate pointers
|
||||||
|
|
||||||
L1: cmp #$0a ; LF?
|
L1: cmp #$0a ; LF?
|
||||||
beq newline ; Recalculate pointers
|
beq newline ; Recalculate pointers
|
||||||
|
|
||||||
; Printable char of some sort
|
; Printable char of some sort
|
||||||
|
|
||||||
cputdirect:
|
cputdirect:
|
||||||
jsr putchar ; Write the character to the screen
|
jsr putchar ; Write the character to the screen
|
||||||
|
|
||||||
; Advance cursor position
|
; Advance cursor position
|
||||||
|
|
||||||
advance:
|
advance:
|
||||||
ldy CURS_X
|
ldy CURS_X
|
||||||
iny
|
iny
|
||||||
cpy #xsize
|
cpy #xsize
|
||||||
bne L3
|
bne L3
|
||||||
jsr newline ; new line
|
jsr newline ; new line
|
||||||
ldy #0 ; + cr
|
ldy #0 ; + cr
|
||||||
L3: sty CURS_X
|
L3: sty CURS_X
|
||||||
jmp plot
|
jmp plot
|
||||||
;rts
|
|
||||||
|
|
||||||
newline:
|
newline:
|
||||||
; lda #xsize
|
inc CURS_Y
|
||||||
; clc
|
|
||||||
; adc SCREEN_PTR
|
|
||||||
; sta SCREEN_PTR
|
|
||||||
; bcc L4
|
|
||||||
; inc SCREEN_PTR+1
|
|
||||||
;; clc
|
|
||||||
;L4:; lda #xsize
|
|
||||||
; adc CRAM_PTR
|
|
||||||
; sta CRAM_PTR
|
|
||||||
; bcc L5
|
|
||||||
; inc CRAM_PTR+1
|
|
||||||
;L5:
|
|
||||||
|
|
||||||
inc CURS_Y
|
|
||||||
|
|
||||||
; jmp plot
|
|
||||||
; rts
|
|
||||||
|
|
||||||
; Set cursor position, calculate RAM pointers
|
; Set cursor position, calculate RAM pointers
|
||||||
|
|
||||||
plot: ldy CURS_X
|
plot: ldy CURS_X
|
||||||
ldx CURS_Y
|
ldx CURS_Y
|
||||||
clc
|
clc
|
||||||
jmp PLOT ; Set the new cursor
|
jmp PLOT ; Set the new cursor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -84,34 +62,32 @@ plot: ldy CURS_X
|
|||||||
|
|
||||||
putchar:
|
putchar:
|
||||||
|
|
||||||
ora RVS ; Set revers bit
|
ora RVS ; Set revers bit
|
||||||
|
|
||||||
tax
|
tax
|
||||||
|
|
||||||
st0 #VDC_MAWR ; Memory Adress Write
|
st0 #VDC_MAWR ; Memory Adress Write
|
||||||
|
|
||||||
lda SCREEN_PTR
|
lda SCREEN_PTR
|
||||||
staio VDC_DATA_LO
|
staio VDC_DATA_LO
|
||||||
|
|
||||||
lda SCREEN_PTR+1
|
lda SCREEN_PTR+1
|
||||||
staio VDC_DATA_HI
|
staio VDC_DATA_HI
|
||||||
|
|
||||||
st0 #VDC_VWR ; VWR
|
st0 #VDC_VWR ; VWR
|
||||||
|
|
||||||
txa
|
txa
|
||||||
staio VDC_DATA_LO ; character
|
staio VDC_DATA_LO ; character
|
||||||
|
|
||||||
;;st2 #$32 ; attrib ?!
|
lda CHARCOLOR
|
||||||
lda CHARCOLOR
|
|
||||||
|
|
||||||
;;lda #2
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
|
|
||||||
and #$f0
|
asl a
|
||||||
ora #$02
|
asl a
|
||||||
staio VDC_DATA_HI
|
asl a
|
||||||
|
asl a
|
||||||
|
|
||||||
rts
|
and #$f0
|
||||||
|
ora #$02
|
||||||
|
staio VDC_DATA_HI
|
||||||
|
|
||||||
|
rts
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
.import __DATA_LOAD__,__DATA_RUN__, __DATA_SIZE__ ; Linker generated
|
.import __DATA_LOAD__,__DATA_RUN__, __DATA_SIZE__ ; Linker generated
|
||||||
.import __BSS_SIZE__
|
.import __BSS_SIZE__
|
||||||
|
|
||||||
.include "pcengine.inc"
|
.include "pce.inc"
|
||||||
|
|
||||||
.importzp sp
|
.importzp sp
|
||||||
.importzp ptr1,ptr2
|
.importzp ptr1,ptr2
|
||||||
@@ -84,10 +84,9 @@ start:
|
|||||||
sta IRQ_MASK ; Interrupts off
|
sta IRQ_MASK ; Interrupts off
|
||||||
stz IRQ_STATUS ; Acknowledge timer
|
stz IRQ_STATUS ; Acknowledge timer
|
||||||
|
|
||||||
;; i dont know why the heck this one doesnt
|
;; FIXME; i dont know why the heck this one doesnt work when called from a constructor :/
|
||||||
;; work when called from a constructor :/
|
.import vdc_init
|
||||||
.import vdc_init
|
jsr vdc_init
|
||||||
jsr vdc_init
|
|
||||||
|
|
||||||
;; jsr joy_init
|
;; jsr joy_init
|
||||||
|
|
||||||
@@ -167,6 +166,7 @@ start:
|
|||||||
|
|
||||||
jsr initlib
|
jsr initlib
|
||||||
|
|
||||||
|
;; FIXME: this should be called from a constructor instead
|
||||||
.import initconio
|
.import initconio
|
||||||
jsr initconio
|
jsr initconio
|
||||||
|
|
||||||
|
|||||||
161
libsrc/pce/ctype.s
Normal file
161
libsrc/pce/ctype.s
Normal 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
|
||||||
|
|
||||||
|
|
||||||
@@ -1,19 +1,16 @@
|
|||||||
;
|
;
|
||||||
; Ullrich von Bassewitz, 06.08.1998
|
|
||||||
;
|
|
||||||
; void gotoxy (unsigned char x, unsigned char y);
|
; void gotoxy (unsigned char x, unsigned char y);
|
||||||
;
|
;
|
||||||
|
|
||||||
.export _gotoxy
|
.export _gotoxy
|
||||||
.import popa, plot
|
.import popa, plot
|
||||||
|
|
||||||
.include "pcengine.inc"
|
.include "pce.inc"
|
||||||
|
|
||||||
_gotoxy:
|
_gotoxy:
|
||||||
|
sta CURS_Y ; Set Y
|
||||||
sta CURS_Y ; Set Y
|
jsr popa ; Get X
|
||||||
jsr popa ; Get X
|
sta CURS_X ; Set X
|
||||||
sta CURS_X ; Set X
|
jmp plot ; Set the cursor position
|
||||||
jmp plot ; Set the cursor position
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
162
libsrc/pce/joy/pce-stdjoy.s
Normal file
162
libsrc/pce/joy/pce-stdjoy.s
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
|
||||||
|
;
|
||||||
|
; Standard joystick driver for the PCEngine
|
||||||
|
;
|
||||||
|
|
||||||
|
.include "joy-kernel.inc"
|
||||||
|
.include "joy-error.inc"
|
||||||
|
|
||||||
|
.macpack module
|
||||||
|
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
; Header. Includes jump table
|
||||||
|
|
||||||
|
module_header _pce_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)
|
||||||
|
|
||||||
|
;extern const unsigned char joy_masks[8];
|
||||||
|
|
||||||
|
.export _joy_masks
|
||||||
|
|
||||||
|
_joy_masks:
|
||||||
|
.byte $10 ; JOY_UP
|
||||||
|
.byte $40 ; JOY_DOWN
|
||||||
|
.byte $80 ; JOY_LEFT
|
||||||
|
.byte $20 ; JOY_RIGHT
|
||||||
|
.byte $02 ; JOY_FIRE A ; FIXME: is this correct?
|
||||||
|
.byte $01 ; JOY_FIRE B ; FIXME: is this correct?
|
||||||
|
.byte $04 ; JOY_START ; FIXME: is this correct?
|
||||||
|
.byte $08 ; JOY_SELECT ; FIXME: is this correct?
|
||||||
|
|
||||||
|
; Jump table.
|
||||||
|
|
||||||
|
.addr INSTALL
|
||||||
|
.addr UNINSTALL
|
||||||
|
.addr COUNT
|
||||||
|
.addr READJOY
|
||||||
|
.addr 0 ; IRQ entry unused
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
; Constants
|
||||||
|
|
||||||
|
JOY_COUNT = 4 ; 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 DEINSTALL 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:
|
||||||
|
pha
|
||||||
|
jsr read_joy
|
||||||
|
pla
|
||||||
|
tax ; Joystick number into X
|
||||||
|
|
||||||
|
; return value from buffer
|
||||||
|
|
||||||
|
joy1:
|
||||||
|
lda padbuffer,x
|
||||||
|
ldx #0
|
||||||
|
rts
|
||||||
|
|
||||||
|
read_joy:
|
||||||
|
; reset multitap counter
|
||||||
|
lda #$01
|
||||||
|
sta $1000
|
||||||
|
pha
|
||||||
|
pla
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
|
||||||
|
lda #$03
|
||||||
|
sta $1000
|
||||||
|
pha
|
||||||
|
pla
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
|
||||||
|
cly
|
||||||
|
nextpad:
|
||||||
|
lda #$01
|
||||||
|
sta $1000 ; sel = 1
|
||||||
|
pha
|
||||||
|
pla
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
|
||||||
|
lda $1000
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
asl a
|
||||||
|
sta padbuffer, y ; store new value
|
||||||
|
|
||||||
|
stz $1000
|
||||||
|
pha
|
||||||
|
pla
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
|
||||||
|
lda $1000
|
||||||
|
and #$0F
|
||||||
|
ora padbuffer, y ; second half of new value
|
||||||
|
|
||||||
|
eor #$FF
|
||||||
|
sta padbuffer, y ; store new value
|
||||||
|
|
||||||
|
iny
|
||||||
|
cpy #$05
|
||||||
|
bcc nextpad
|
||||||
|
rts
|
||||||
|
|
||||||
|
.bss
|
||||||
|
|
||||||
|
padbuffer:
|
||||||
|
.res 4
|
||||||
|
|
||||||
14
libsrc/pce/joy_stat_stddrv.s
Normal file
14
libsrc/pce/joy_stat_stddrv.s
Normal 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 _pce_stdjoy_joy
|
||||||
|
|
||||||
|
.rodata
|
||||||
|
|
||||||
|
_joy_static_stddrv := _pce_stdjoy_joy
|
||||||
13
libsrc/pce/joy_stddrv.s
Normal file
13
libsrc/pce/joy_stddrv.s
Normal 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 "pce-stdjoy.joy"
|
||||||
@@ -1,275 +0,0 @@
|
|||||||
;
|
|
||||||
; File generated by cc65 v 2.9.5
|
|
||||||
;
|
|
||||||
.fopt compiler,"cc65 v 2.9.5"
|
|
||||||
.autoimport on
|
|
||||||
.case on
|
|
||||||
.debuginfo off
|
|
||||||
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
|
|
||||||
.macpack longbranch
|
|
||||||
.import _joy_masks
|
|
||||||
.import _joy_read
|
|
||||||
.import _clock
|
|
||||||
.export _kbhit
|
|
||||||
.export _cgetc
|
|
||||||
|
|
||||||
.segment "DATA"
|
|
||||||
|
|
||||||
__lastkey:
|
|
||||||
.byte $00
|
|
||||||
__chardelay:
|
|
||||||
.dword $00000000
|
|
||||||
_rptkey:
|
|
||||||
.byte $00
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------
|
|
||||||
; void _getkey (void)
|
|
||||||
; ---------------------------------------------------------------
|
|
||||||
|
|
||||||
.segment "CODE"
|
|
||||||
|
|
||||||
.proc __getkey
|
|
||||||
|
|
||||||
.segment "CODE"
|
|
||||||
|
|
||||||
jsr decsp2
|
|
||||||
ldx #$00
|
|
||||||
lda __lastkey
|
|
||||||
cmp #$00
|
|
||||||
jsr booleq
|
|
||||||
jeq L003F
|
|
||||||
lda #$00
|
|
||||||
jsr _joy_read
|
|
||||||
ldy #$01
|
|
||||||
sta (sp),y
|
|
||||||
ldx #$00
|
|
||||||
lda #$00
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
ldy #$01
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jsr pushax
|
|
||||||
ldx #$00
|
|
||||||
lda _joy_masks+4
|
|
||||||
jsr tosandax
|
|
||||||
stx tmp1
|
|
||||||
ora tmp1
|
|
||||||
jeq L0010
|
|
||||||
ldx #$00
|
|
||||||
lda #$0A
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
jmp L003A
|
|
||||||
L0010: ldy #$01
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jsr pushax
|
|
||||||
ldx #$00
|
|
||||||
lda _joy_masks
|
|
||||||
jsr tosandax
|
|
||||||
stx tmp1
|
|
||||||
ora tmp1
|
|
||||||
jeq L0016
|
|
||||||
ldx #$00
|
|
||||||
lda #$01
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
jmp L003A
|
|
||||||
L0016: ldy #$01
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jsr pushax
|
|
||||||
ldx #$00
|
|
||||||
lda _joy_masks+2
|
|
||||||
jsr tosandax
|
|
||||||
stx tmp1
|
|
||||||
ora tmp1
|
|
||||||
jeq L001C
|
|
||||||
ldx #$00
|
|
||||||
lda #$03
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
jmp L003A
|
|
||||||
L001C: ldy #$01
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jsr pushax
|
|
||||||
ldx #$00
|
|
||||||
lda _joy_masks+3
|
|
||||||
jsr tosandax
|
|
||||||
stx tmp1
|
|
||||||
ora tmp1
|
|
||||||
jeq L0022
|
|
||||||
ldx #$00
|
|
||||||
lda #$04
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
jmp L003A
|
|
||||||
L0022: ldy #$01
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jsr pushax
|
|
||||||
ldx #$00
|
|
||||||
lda _joy_masks+1
|
|
||||||
jsr tosandax
|
|
||||||
stx tmp1
|
|
||||||
ora tmp1
|
|
||||||
jeq L0028
|
|
||||||
ldx #$00
|
|
||||||
lda #$02
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
jmp L003A
|
|
||||||
L0028: ldy #$01
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jsr pushax
|
|
||||||
ldx #$00
|
|
||||||
lda _joy_masks+7
|
|
||||||
jsr tosandax
|
|
||||||
stx tmp1
|
|
||||||
ora tmp1
|
|
||||||
jeq L002E
|
|
||||||
ldx #$00
|
|
||||||
lda #$14
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
jmp L003A
|
|
||||||
L002E: ldy #$01
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jsr pushax
|
|
||||||
ldx #$00
|
|
||||||
lda _joy_masks+5
|
|
||||||
jsr tosandax
|
|
||||||
stx tmp1
|
|
||||||
ora tmp1
|
|
||||||
jeq L0034
|
|
||||||
ldx #$00
|
|
||||||
lda #$15
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
jmp L003A
|
|
||||||
L0034: ldy #$01
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jsr pushax
|
|
||||||
ldx #$00
|
|
||||||
lda _joy_masks+6
|
|
||||||
jsr tosandax
|
|
||||||
stx tmp1
|
|
||||||
ora tmp1
|
|
||||||
jeq L003A
|
|
||||||
ldx #$00
|
|
||||||
lda #$16
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
L003A: ldy #$00
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
cmp #$00
|
|
||||||
jsr boolne
|
|
||||||
jeq L003F
|
|
||||||
ldy #$00
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jsr pushax
|
|
||||||
ldx #$00
|
|
||||||
lda _rptkey
|
|
||||||
jsr toseqax
|
|
||||||
jeq L0043
|
|
||||||
lda __chardelay+3
|
|
||||||
sta sreg+1
|
|
||||||
lda __chardelay+2
|
|
||||||
sta sreg
|
|
||||||
ldx __chardelay+1
|
|
||||||
lda __chardelay
|
|
||||||
jsr pusheax
|
|
||||||
jsr _clock
|
|
||||||
jsr tosugteax
|
|
||||||
jeq L0043
|
|
||||||
jmp L003F
|
|
||||||
L0043: ldy #$00
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
sta _rptkey
|
|
||||||
jsr _clock
|
|
||||||
ldy #$06
|
|
||||||
jsr inceaxy
|
|
||||||
sta __chardelay
|
|
||||||
stx __chardelay+1
|
|
||||||
ldy sreg
|
|
||||||
sty __chardelay+2
|
|
||||||
ldy sreg+1
|
|
||||||
sty __chardelay+3
|
|
||||||
ldy #$00
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
sta __lastkey
|
|
||||||
L003F: jsr incsp2
|
|
||||||
rts
|
|
||||||
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------
|
|
||||||
; unsigned char __fastcall__ kbhit (void)
|
|
||||||
; ---------------------------------------------------------------
|
|
||||||
|
|
||||||
.segment "CODE"
|
|
||||||
|
|
||||||
.proc _kbhit
|
|
||||||
|
|
||||||
.segment "CODE"
|
|
||||||
|
|
||||||
jsr __getkey
|
|
||||||
ldx #$00
|
|
||||||
lda __lastkey
|
|
||||||
cmp #$00
|
|
||||||
jsr booleq
|
|
||||||
jeq L004E
|
|
||||||
ldx #$00
|
|
||||||
lda #$00
|
|
||||||
jmp L0052
|
|
||||||
jmp L0052
|
|
||||||
L004E: ldx #$00
|
|
||||||
lda #$01
|
|
||||||
jmp L0052
|
|
||||||
L0052: rts
|
|
||||||
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------
|
|
||||||
; unsigned char __fastcall__ cgetc (void)
|
|
||||||
; ---------------------------------------------------------------
|
|
||||||
|
|
||||||
.segment "CODE"
|
|
||||||
|
|
||||||
.proc _cgetc
|
|
||||||
|
|
||||||
.segment "CODE"
|
|
||||||
|
|
||||||
jsr decsp1
|
|
||||||
L0056: ldx #$00
|
|
||||||
lda __lastkey
|
|
||||||
cmp #$00
|
|
||||||
jsr booleq
|
|
||||||
jeq L0057
|
|
||||||
jsr __getkey
|
|
||||||
jmp L0056
|
|
||||||
L0057: ldx #$00
|
|
||||||
lda __lastkey
|
|
||||||
ldy #$00
|
|
||||||
sta (sp),y
|
|
||||||
ldx #$00
|
|
||||||
lda #$00
|
|
||||||
sta __lastkey
|
|
||||||
ldy #$00
|
|
||||||
ldx #$00
|
|
||||||
lda (sp),y
|
|
||||||
jmp L0055
|
|
||||||
L0055: jsr incsp1
|
|
||||||
rts
|
|
||||||
|
|
||||||
.endproc
|
|
||||||
|
|
||||||
@@ -1,41 +1,32 @@
|
|||||||
|
|
||||||
.export PLOT
|
.export PLOT
|
||||||
|
|
||||||
.include "pcengine.inc"
|
.include "pce.inc"
|
||||||
|
|
||||||
PLOT:
|
PLOT:
|
||||||
|
bcs @getpos
|
||||||
|
|
||||||
bcs @getpos
|
tya
|
||||||
|
clc
|
||||||
tya
|
adc _plotlo,x
|
||||||
clc
|
sta SCREEN_PTR
|
||||||
adc _plotlo,x
|
|
||||||
sta SCREEN_PTR
|
|
||||||
|
|
||||||
lda _plothi,x
|
|
||||||
adc #0
|
|
||||||
sta SCREEN_PTR+1
|
|
||||||
|
|
||||||
;clc
|
|
||||||
;adc _colplot,x
|
|
||||||
;sta CRAM_PTR
|
|
||||||
|
|
||||||
;lda #$23
|
|
||||||
;sta CRAM_PTR+1
|
|
||||||
|
|
||||||
|
lda _plothi,x
|
||||||
|
adc #0
|
||||||
|
sta SCREEN_PTR+1
|
||||||
@getpos:
|
@getpos:
|
||||||
ldx CURS_Y
|
ldx CURS_Y
|
||||||
ldy CURS_X
|
ldy CURS_X
|
||||||
rts
|
rts
|
||||||
|
|
||||||
_plotlo:
|
_plotlo:
|
||||||
.repeat screenrows,line
|
.repeat screenrows,line
|
||||||
.byte <($0000+(line*$80))
|
.byte <($0000+(line*$80))
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
_plothi:
|
_plothi:
|
||||||
.repeat screenrows,line
|
.repeat screenrows,line
|
||||||
.byte >($0000+(line*$80))
|
.byte >($0000+(line*$80))
|
||||||
.endrepeat
|
.endrepeat
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
8
libsrc/pce/libref.s
Normal file
8
libsrc/pce/libref.s
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
;
|
||||||
|
; Oliver Schmidt, 2013-05-31
|
||||||
|
;
|
||||||
|
|
||||||
|
.export joy_libref
|
||||||
|
.import _exit
|
||||||
|
|
||||||
|
joy_libref := _exit
|
||||||
@@ -1,191 +0,0 @@
|
|||||||
|
|
||||||
;
|
|
||||||
; Standard joystick driver for the PCEngine
|
|
||||||
;
|
|
||||||
; Ullrich von Bassewitz, 2002-12-20
|
|
||||||
;
|
|
||||||
|
|
||||||
;;.include "zeropage.inc"
|
|
||||||
|
|
||||||
;;.include "joy-kernel.inc"
|
|
||||||
|
|
||||||
;;.include "joy-error.inc"
|
|
||||||
JOY_ERR_OK=0;
|
|
||||||
.include "pcengine.inc"
|
|
||||||
|
|
||||||
.macpack generic
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
|
||||||
; Header. Includes jump table
|
|
||||||
|
|
||||||
.segment "CODE"
|
|
||||||
|
|
||||||
; Driver signature
|
|
||||||
|
|
||||||
;; .byte $6A, $6F, $79 ; "joy"
|
|
||||||
;; .byte $00 ; Driver API version number
|
|
||||||
|
|
||||||
; Button state masks (8 values)
|
|
||||||
|
|
||||||
;extern const unsigned char joy_masks[8];
|
|
||||||
|
|
||||||
.export _joy_masks
|
|
||||||
|
|
||||||
_joy_masks:
|
|
||||||
.byte $10 ; JOY_UP
|
|
||||||
.byte $40 ; JOY_DOWN
|
|
||||||
.byte $80 ; JOY_LEFT
|
|
||||||
.byte $20 ; JOY_RIGHT
|
|
||||||
.byte $04 ; ? JOY_FIRE
|
|
||||||
.byte $02 ; ? Future expansion
|
|
||||||
.byte $01 ; ? Future expansion
|
|
||||||
.byte $08 ; ? Future expansion
|
|
||||||
|
|
||||||
; Jump table.
|
|
||||||
|
|
||||||
;; .word INSTALL
|
|
||||||
;; .word DEINSTALL
|
|
||||||
;; .word COUNT
|
|
||||||
;; .word READ
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
|
||||||
; Constants
|
|
||||||
|
|
||||||
JOY_COUNT = 4 ; Number of joysticks we support
|
|
||||||
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
|
||||||
; Data.
|
|
||||||
|
|
||||||
|
|
||||||
.code
|
|
||||||
|
|
||||||
|
|
||||||
;extern const char joy_stddrv[];
|
|
||||||
|
|
||||||
.export _joy_stddrv
|
|
||||||
_joy_stddrv:
|
|
||||||
.byte 0
|
|
||||||
|
|
||||||
|
|
||||||
.export _joy_load_driver
|
|
||||||
.export _joy_unload
|
|
||||||
|
|
||||||
;unsigned char __fastcall__ joy_unload (void);
|
|
||||||
;unsigned char __fastcall__ joy_load_driver (const char* driver);
|
|
||||||
_joy_load_driver:
|
|
||||||
_joy_unload:
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
|
||||||
; 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 DEINSTALL instead
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
|
||||||
; DEINSTALL routine. Is called before the driver is removed from memory.
|
|
||||||
; Can do cleanup or whatever. Must not return anything.
|
|
||||||
;
|
|
||||||
|
|
||||||
DEINSTALL:
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
|
||||||
; COUNT: Return the total number of available joysticks in a/x.
|
|
||||||
;
|
|
||||||
;unsigned char __fastcall__ joy_count (void);
|
|
||||||
|
|
||||||
.export _joy_count
|
|
||||||
|
|
||||||
_joy_count:
|
|
||||||
COUNT:
|
|
||||||
lda #<JOY_COUNT
|
|
||||||
ldx #>JOY_COUNT
|
|
||||||
rts
|
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
|
||||||
; READ: Read a particular joystick passed in A.
|
|
||||||
;
|
|
||||||
;unsigned char __fastcall__ joy_read (unsigned char joystick);
|
|
||||||
|
|
||||||
.export _joy_read
|
|
||||||
|
|
||||||
_joy_read:
|
|
||||||
READ:
|
|
||||||
pha
|
|
||||||
jsr read_joy
|
|
||||||
pla
|
|
||||||
tax ; Joystick number into X
|
|
||||||
|
|
||||||
; return value from buffer
|
|
||||||
|
|
||||||
joy1:
|
|
||||||
lda padbuffer,x
|
|
||||||
ldx #0
|
|
||||||
rts
|
|
||||||
|
|
||||||
.code
|
|
||||||
|
|
||||||
read_joy:
|
|
||||||
; reset multitap counter
|
|
||||||
lda #$01
|
|
||||||
sta $1000
|
|
||||||
pha
|
|
||||||
pla
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
|
|
||||||
lda #$03
|
|
||||||
sta $1000
|
|
||||||
pha
|
|
||||||
pla
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
|
|
||||||
cly
|
|
||||||
nextpad:
|
|
||||||
lda #$01
|
|
||||||
sta $1000 ; sel = 1
|
|
||||||
pha
|
|
||||||
pla
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
|
|
||||||
lda $1000
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
asl a
|
|
||||||
sta padbuffer, y ; store new value
|
|
||||||
|
|
||||||
stz $1000
|
|
||||||
pha
|
|
||||||
pla
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
|
|
||||||
lda $1000
|
|
||||||
and #$0F
|
|
||||||
ora padbuffer, y ; second half of new value
|
|
||||||
|
|
||||||
eor #$FF
|
|
||||||
sta padbuffer, y ; store new value
|
|
||||||
|
|
||||||
iny
|
|
||||||
cpy #$05
|
|
||||||
bcc nextpad
|
|
||||||
rts
|
|
||||||
|
|
||||||
.bss
|
|
||||||
|
|
||||||
padbuffer:
|
|
||||||
.res 4
|
|
||||||
|
|
||||||
@@ -1,29 +1,29 @@
|
|||||||
|
|
||||||
.include "pcengine.inc"
|
|
||||||
|
|
||||||
.export psg_init
|
.include "pce.inc"
|
||||||
|
|
||||||
|
.export psg_init
|
||||||
|
|
||||||
psg_init:
|
psg_init:
|
||||||
clx
|
clx
|
||||||
stx $0800 ; Select channel
|
stx $0800 ; Select channel
|
||||||
psg_clear_loop:
|
psg_clear_loop:
|
||||||
stz $0801 ; Clear global balance
|
stz $0801 ; Clear global balance
|
||||||
stz $0802 ; Clear frequency LSB
|
stz $0802 ; Clear frequency LSB
|
||||||
stz $0803 ; Clear frequency MSB
|
stz $0803 ; Clear frequency MSB
|
||||||
stz $0804 ; Clear volume
|
stz $0804 ; Clear volume
|
||||||
stz $0805 ; Clear balance
|
stz $0805 ; Clear balance
|
||||||
stz $0807 ; Clear noise control
|
stz $0807 ; Clear noise control
|
||||||
stz $0808 ; Clear LFO frequency
|
stz $0808 ; Clear LFO frequency
|
||||||
stz $0809 ; Clear LFO control
|
stz $0809 ; Clear LFO control
|
||||||
|
|
||||||
cly
|
cly
|
||||||
psg_clear_waveform: stz $0806 ; Clear waveform byte
|
psg_clear_waveform: stz $0806 ; Clear waveform byte
|
||||||
iny
|
iny
|
||||||
cpy #$20
|
cpy #$20
|
||||||
bne psg_clear_waveform
|
bne psg_clear_waveform
|
||||||
|
|
||||||
|
inx
|
||||||
|
cpx #$06
|
||||||
|
bne psg_clear_loop
|
||||||
|
rts
|
||||||
|
|
||||||
inx
|
|
||||||
cpx #$06
|
|
||||||
bne psg_clear_loop
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
|||||||
31
libsrc/pce/readme.txt
Normal file
31
libsrc/pce/readme.txt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
joystick support should get verified on real hw, the masks for buttons may be
|
||||||
|
wrong.
|
||||||
|
|
||||||
|
clock() does not work for unknown reasons
|
||||||
|
|
||||||
|
get_tv() is a dummy function and always returns 0
|
||||||
|
|
||||||
|
revers() is a dummy function, actual reverse output is not supported yet
|
||||||
|
|
||||||
|
waitvblank() is missing
|
||||||
|
|
||||||
|
some graphical petscii chars should get added to the charset
|
||||||
|
|
||||||
|
conio-init should get initialized from a constructor rather than always get
|
||||||
|
called from crt0
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
a good emulator to use for PC-Engine is "mednafen" (mednafen.sourceforge.net)
|
||||||
|
|
||||||
|
run the compiled binary like this:
|
||||||
|
|
||||||
|
> mednafen -force_module pce <yourprogram.pce>
|
||||||
|
|
||||||
|
joypad keys are mapped like this:
|
||||||
|
|
||||||
|
w/s/a/d up/down/left/right
|
||||||
|
numpad 2 (?) button
|
||||||
|
numpad 3 (?) button
|
||||||
|
enter (start) button
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
.export _revers
|
.export _revers
|
||||||
_revers:
|
_revers:
|
||||||
lda #0
|
lda #0
|
||||||
rts
|
rts
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
.include "pcengine.inc"
|
.include "pce.inc"
|
||||||
|
|
||||||
.export vce_init
|
.export vce_init
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
.include "pcengine.inc"
|
.include "pce.inc"
|
||||||
|
|
||||||
HIRES = 1
|
HIRES = 1
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
#include <conio.h>
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
clrscr();
|
|
||||||
// cprintf("hello world");
|
|
||||||
cputs("hello world");
|
|
||||||
for(;;);
|
|
||||||
}
|
|
||||||
58
testcode/lib/pce/conio.c
Normal file
58
testcode/lib/pce/conio.c
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
#include <conio.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <joystick.h>
|
||||||
|
|
||||||
|
static int datavar = 10;
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
int stackvar = 42;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
joy_install(&joy_static_stddrv);
|
||||||
|
|
||||||
|
clrscr();
|
||||||
|
|
||||||
|
cputs("hello world");
|
||||||
|
cputsxy(0, 2, "colors:" );
|
||||||
|
for (i = 0; i < 16; ++i) {
|
||||||
|
textcolor(i);
|
||||||
|
cputc('X');
|
||||||
|
}
|
||||||
|
textcolor(1);
|
||||||
|
|
||||||
|
gotoxy(0,4);
|
||||||
|
cprintf("datavar: %02x\n\r", datavar);
|
||||||
|
cprintf("stackvar: %02x\n\r", stackvar);
|
||||||
|
|
||||||
|
j = joy_count();
|
||||||
|
gotoxy(0,10);
|
||||||
|
cprintf("Found %d Joysticks.", j);
|
||||||
|
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
gotoxy(13,4);
|
||||||
|
cprintf("%02x", datavar);
|
||||||
|
gotoxy(13,5);
|
||||||
|
cprintf("%02x", stackvar);
|
||||||
|
++datavar; ++stackvar;
|
||||||
|
|
||||||
|
gotoxy(0,8);
|
||||||
|
cprintf("clock: %08x", clock());
|
||||||
|
for (i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
gotoxy(0, 12 + i);
|
||||||
|
j = joy_read (i);
|
||||||
|
cprintf ("pad %d: %02x %-6s%-6s%-6s%-6s%-6s%-6s",
|
||||||
|
i, j,
|
||||||
|
(j & joy_masks[JOY_UP])? " up " : " ---- ",
|
||||||
|
(j & joy_masks[JOY_DOWN])? " down " : " ---- ",
|
||||||
|
(j & joy_masks[JOY_LEFT])? " left " : " ---- ",
|
||||||
|
(j & joy_masks[JOY_RIGHT])? "right " : " ---- ",
|
||||||
|
(j & joy_masks[JOY_FIRE])? " fire " : " ---- ",
|
||||||
|
(j & joy_masks[JOY_FIRE2])? "fire2 " : " ---- ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(;;);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user