]> git.sur5r.net Git - cc65/commitdiff
more cleanup, joystick works again
authormrdudz <mrdudz@users.noreply.github.com>
Sun, 12 Jul 2015 12:27:24 +0000 (14:27 +0200)
committermrdudz <mrdudz@users.noreply.github.com>
Sun, 12 Jul 2015 12:27:24 +0000 (14:27 +0200)
28 files changed:
asminc/pce.inc [new file with mode: 0644]
cfg/pce.cfg
include/pce.h
libsrc/pce/call.s
libsrc/pce/clock.s
libsrc/pce/clrscr.s
libsrc/pce/color.s
libsrc/pce/condes.s
libsrc/pce/conio.s
libsrc/pce/cputc.s
libsrc/pce/crt0.s
libsrc/pce/ctype.s [new file with mode: 0644]
libsrc/pce/gotoxy.s
libsrc/pce/joy/pce-stdjoy.s [new file with mode: 0644]
libsrc/pce/joy_stat_stddrv.s [new file with mode: 0644]
libsrc/pce/joy_stddrv.s [new file with mode: 0644]
libsrc/pce/joytokbd.s [deleted file]
libsrc/pce/kplot.s
libsrc/pce/libref.s [new file with mode: 0644]
libsrc/pce/pce-stdjoy.s [deleted file]
libsrc/pce/pcengine.inc [deleted file]
libsrc/pce/psg.s
libsrc/pce/readme.txt [new file with mode: 0644]
libsrc/pce/revers.s
libsrc/pce/vce.s
libsrc/pce/vdc.s
testcode/lib/conio.c [deleted file]
testcode/lib/pce/conio.c [new file with mode: 0644]

diff --git a/asminc/pce.inc b/asminc/pce.inc
new file mode 100644 (file)
index 0000000..40e356c
--- /dev/null
@@ -0,0 +1,93 @@
+;
+; PCE definitions. By Groepaz/Hitmem.
+;
+
+;; FIXME: optimize zeropage usage
+
+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)
+charsperline = (512/8)
+xsize = charsperline
+
+CH_HLINE = 7
+CH_VLINE = 7
+
+; huc6270 - Video Display Controller (vdc)
+
+VDC_MAWR = 0 ; Memory Address Write Register
+VDC_MARR = 1 ; Memory Address Read Register
+VDC_VWR  = 2 ; VRAM Write Register
+VDC_VRR  = 3 ; VRAM Read Register
+VDC_CR   = 4 ; Control Register
+VDC_RCR  = 5 ; Raster Counter Register
+VDC_BXR  = 6 ; Background X-Scroll Register
+VDC_BYR  = 7 ; Background Y-Scroll Register
+VDC_MWR  = 8 ; Memory-access Width Register
+VDC_HSR  = 9 ; Horizontal Sync Register (?)
+VDC_HDR  =10 ; Horizontal Display Register (?)
+VDC_VPR  =11 ; (unknown)
+VDC_VDW  =12 ; (unknown use)
+VDC_VCR  =13 ; (unknown use)
+VDC_DCR  =14 ; (DMA) Control Register
+VDC_SOUR =15 ; (DMA) Source Register
+VDC_DESR =16 ; (DMA) Destination Register
+VDC_LENR =17 ; (DMA) Length Register
+VDC_SATB =18 ; Sprite Attribute Table
+
+VDC_CTRL        = $0000
+VDC_DATA_LO     = $0002
+VDC_DATA_HI     = $0003
+
+; huc6260 - Video Color Encoder (vce)
+
+; The DAC has a palette of 512 colours.
+; bitmap of the palette data is this: 0000000gggrrrbbb.
+; You can read and write the DAC-registers.
+
+VCE_CTRL = $0400    ; write$00 to reset
+VCE_ADDR_LO = $0402 ; LSB of byte offset into palette
+VCE_ADDR_HI = $0403 ; MSB of byte offset into palette
+VCE_DATA_LO = $0404 ; LSB of 16-bit palette data
+VCE_DATA_HI = $0405 ; MSB of 16-bit palette data
+
+TIMER_COUNT     = $0c00
+TIMER_CTRL      = $0c01
+
+JOY_CTRL        = $1000
+
+IRQ_MASK        = $1402
+IRQ_STATUS      = $1403
+
+CDR_MEM_DISABLE = $1803
+CDR_MEM_ENABLE  = $1807
+
+;; lda abs
+.macro ldaio arg1
+        .byte $ad
+        .word arg1
+.endmacro
+;; sta abs
+.macro staio arg1
+        .byte $8d
+        .word arg1
+.endmacro
+;; stz abs
+.macro stzio arg1
+        .byte $9c
+        .word arg1
+.endmacro
+
+; Write VDC register
+.macro VREG arg1,arg2
+        st0     #arg1
+        st1     #<(arg2)
+        st2     #>(arg2)
+.endmacro
index f848fd737042ea50861c3d7cf5f70e56aad0e631..566554b2e00730adee48e7794c1d4655781fb6ac 100644 (file)
@@ -1,62 +1,32 @@
+# linker config to produce simple NEC PC-Engine cartridge (.pce)
+
 SYMBOLS {
         __STACKSIZE__: type = weak, value = $0300; # 3 pages stack
 }
-MEMORY {
-
-       ZP:  start = $00, size = $1A, type = rw, define = yes;
-
-       # INES Cartridge Header
-       #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;
+MEMORY {
+        # FIXME: is this correct? the first 3? bytes cant be used?
+        ZP:  start = $03, size = $1A, type = rw, 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;
+        # reset-bank and hardware vectors
+        ROM0: start = $e000, size = $1ff6, file = %O ,fill = yes, define = yes;
+        ROMV: start = $fff6, size = $a, file = %O,fill = yes;
 
+        # first RAM page (also contains stack and zeropage)
+        RAM: start = $2200, size = $1e00, define = yes;
 }
-SEGMENTS {
-    #HEADER: load = HEADER, type = wprot;
-
-    #aSTARTUP: load = ROM0, type = wprot, define = yes;
-    STARTUP: load = ROM0, type = ro, define = yes;
-
-    INIT:     load = ROM0,            type = ro,  define = yes, optional = yes;
-       CODE: load = ROM0, type = ro, define = yes;
-    RODATA: load = ROM0, type = ro, 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;
 
+SEGMENTS {
+        STARTUP: load = ROM0, type = ro, define = yes;
+        INIT:    load = ROM0, type = ro, define = yes, optional = yes;
+        CODE:    load = ROM0, type = ro, define = yes;
+        RODATA:  load = ROM0, type = ro, define = yes;
+        DATA:    load = ROM0, run= RAM, type = rw, define = yes;
+        BSS:     load = RAM, type = bss, define = yes;
+        VECTORS: load = ROMV, type = rw, define = yes;
+        ZEROPAGE: load = ZP, type = zp, define = yes;
 }
+
 FEATURES {
         CONDES: segment = STARTUP,
         type=constructor,
index 8135679a2d6de26913370e63a979d3d741768c22..70d5800d0da7c51c30d18d9939a722b86bc2efaa 100644 (file)
@@ -1,74 +1,99 @@
-#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
-
-
-#define TV_NTSC        0
-#define TV_PAL         1
-#define get_tv()       0
-
-#define CLOCKS_PER_SEC         50              // ???
-#define CLK_TCK                                50              // ?!?
-
-//#ifndef CH_ENTER
-#define CH_ENTER       '\n'
-//#endif
-
-#define CH_STOP        0x08
-
-#define CH_F1          0x14
-#define CH_F3          0x15
-#define CH_F5          0x16
-#define CH_F7          0x17
-
-#define CH_CURS_UP             0x01
-#define CH_CURS_DOWN   0x02
-
-#ifndef CH_CURS_LEFT
-#define CH_CURS_LEFT   0x03
+/*****************************************************************************/
+/*                                                                           */
+/*                                   pce.h                                   */
+/*                                                                           */
+/*                   PC-Engine system specific definitions                   */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (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.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef _PCE_H
+#define _PCE_H
+
+
+
+/* Check for errors */
+#if !defined(__PCE__)
+#  error This module may only be used when compiling for the PCE!
 #endif
 
-#ifndef CH_CURS_RIGHT
-#define CH_CURS_RIGHT  0x04
+/* FIXME: the respective characters are not present in the VGA charset (yet) */
+#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
-
-#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);
-*/
index 34fbac08b58b05d572e4493aa521e01a717bad39..db120a72f3b9e456f1d6be69bc4e15f83f079339 100644 (file)
@@ -1,19 +1,17 @@
 ;
-; Ullrich von Bassewitz, 06.08.1998
-;
 ; CC65 runtime: call function via pointer in ax
 ;
 
-       .export         callax
+                .export callax
 
 .code
 
 callax:
-    sta        vec
-       stx     vec+1
-       jmp     (vec)           ; jump there
+                sta     vec
+                stx     vec+1
+                jmp     (vec)   ; jump there
 
 .bss
 
 vec:
-    .res 2
\ No newline at end of file
+                .res 2
\ No newline at end of file
index 60096c81d3fa7557668ca2b187a1b9e7b89fe2ba..5f360916c180999ecdb253aa60b5be894f688689 100644 (file)
@@ -1,17 +1,15 @@
 ;
-; Ullrich von Bassewitz, 21.09.1998
-;
 ; clock_t clock (void);
 ;
 
-        .include "pcengine.inc"
+        .include "pce.inc"
 
-        .export        _clock
+        .export         _clock
         .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
 
@@ -20,4 +18,3 @@
         rts
 
 .endproc
-
index 0a2b8b62d342ff349012b641b54940db1c3e2212..93628ddd8eb633d03b4064ef5903c967f22999e1 100644 (file)
@@ -1,5 +1,5 @@
 
-                .include "pcengine.inc"
+                .include "pce.inc"
 
                 .export _clrscr
 _clrscr:
index 8d80114fcc3a1dd59088721656dc673e60454d43..0ec35f5b340980cbf2c7641ca6e83be1da66099a 100644 (file)
@@ -1,59 +1,57 @@
 ;
-; Ullrich von Bassewitz, 06.08.1998
-;
 ; 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
+                .export     _textcolor, _bgcolor, _bordercolor
 
-       .include        "pcengine.inc"
+                .include    "pce.inc"
 
 _textcolor:
-       ldx     CHARCOLOR       ; get old value
-       sta     CHARCOLOR       ; set new value
-       txa
-       rts
+                ldx     CHARCOLOR       ; get old value
+                sta     CHARCOLOR       ; set new value
+                txa
+                rts
 
 _bgcolor:
-       ldx     BGCOLOR       ; get old value
-       sta     BGCOLOR           ; set new value
-    asl a
-       tay
+                ldx     BGCOLOR         ; get old value
+                sta     BGCOLOR         ; set new value
+                asl a
+                tay
 
-       stz     VCE_ADDR_LO
-    stz     VCE_ADDR_HI
-       lda colors,y
-       sta     VCE_DATA_LO
-       lda colors+1,y
-       sta     VCE_DATA_HI
+                stz     VCE_ADDR_LO
+                stz     VCE_ADDR_HI
+                lda     colors,y
+                sta     VCE_DATA_LO
+                lda     colors+1,y
+                sta     VCE_DATA_HI
 
-       txa
-       rts
+                txa
+                rts
 
 _bordercolor:
-       lda #0
-       txa
-       rts
-
-               .export colors
-
-colors:       ; G      R      B
-               .word ((0<<6)+(0<<3)+(0))               ; 0 black
-               .word ((7<<6)+(7<<3)+(7))           ; 1 white
-               .word ((0<<6)+(7<<3)+(0))           ; 2 red
-               .word ((7<<6)+(0<<3)+(7))           ; 3 cyan
-               .word ((0<<6)+(5<<3)+(7))           ; 4 violett
-               .word ((7<<6)+(0<<3)+(0))           ; 5 green
-               .word ((0<<6)+(0<<3)+(7))           ; 6 blue
-               .word ((7<<6)+(7<<3)+(0))           ; 7 yellow
-               .word ((5<<6)+(7<<3)+(0))           ; 8 orange
-               .word ((3<<6)+(4<<3)+(3))           ; 9 brown
-               .word ((4<<6)+(7<<3)+(4))           ; a light red
-               .word ((3<<6)+(3<<3)+(3))           ; b dark grey
-               .word ((4<<6)+(4<<3)+(4))           ; c middle grey
-               .word ((7<<6)+(4<<3)+(4))           ; d light green
-               .word ((4<<6)+(4<<3)+(7))           ; e light blue
-               .word ((6<<6)+(6<<3)+(6))           ; f light gray
+                lda #0
+                txa
+                rts
+
+                .export colors
+
+colors:               ; G      R      B
+                .word ((0<<6)+(0<<3)+(0))           ; 0 black
+                .word ((7<<6)+(7<<3)+(7))           ; 1 white
+                .word ((0<<6)+(7<<3)+(0))           ; 2 red
+                .word ((7<<6)+(0<<3)+(7))           ; 3 cyan
+                .word ((0<<6)+(5<<3)+(7))           ; 4 violett
+                .word ((7<<6)+(0<<3)+(0))           ; 5 green
+                .word ((0<<6)+(0<<3)+(7))           ; 6 blue
+                .word ((7<<6)+(7<<3)+(0))           ; 7 yellow
+                .word ((5<<6)+(7<<3)+(0))           ; 8 orange
+                .word ((3<<6)+(4<<3)+(3))           ; 9 brown
+                .word ((4<<6)+(7<<3)+(4))           ; a light red
+                .word ((3<<6)+(3<<3)+(3))           ; b dark grey
+                .word ((4<<6)+(4<<3)+(4))           ; c middle grey
+                .word ((7<<6)+(4<<3)+(4))           ; d light green
+                .word ((4<<6)+(4<<3)+(7))           ; e light blue
+                .word ((6<<6)+(6<<3)+(6))           ; f light gray
index dd7bd30b376a1cfd060e3b533ac688b6b7faeb25..aa28833c2cea8d2c5750238c51445edb1377eadd 100644 (file)
@@ -94,9 +94,3 @@ getbyt:
 ;;getbyt_:
        lda     $FFFF,y
        rts
-
-;; callax doesnt work? why?!
-;_callax:
-;    sta @l+1
-;    stx @l+2
-;@l: jmp $dead
index 0a66cf454fe49e07d220eec88c94302f8ef9f094..60801e1729053d0680e6d7da430410ddee837db1 100644 (file)
-                                               .include "pcengine.inc"
-            .import vce_init
-            .import psg_init
-            .import vdc_init
+                .include "pce.inc"
 
-                       .export initconio
-                   .export _conio_init
+                .import vce_init
+                .import psg_init
+                .import vdc_init
 
-                       .constructor initconio, 24
+                .export initconio
+                .export _conio_init
 
-            .macpack longbranch
+                .constructor initconio, 24
+
+                .macpack longbranch
 initconio:
-                     ;;   jsr     vdc_init
-                        jsr     vce_init
-                        jsr     psg_init
-                        jsr     conio_init
-                        jsr     set_palette
-
-                        st0     #VDC_RCR
-                        st1     #<$0088
-                        st2     #>$0088
-                                               rts
-
-                                               .import colors
+;;              jsr     vdc_init
+                jsr     vce_init
+                jsr     psg_init
+                jsr     conio_init
+                jsr     set_palette
+
+                st0     #VDC_RCR
+                st1     #<$0088
+                st2     #>$0088
+                rts
+
+                .import colors
 set_palette:
+                stz     VCE_ADDR_LO
+                stz     VCE_ADDR_HI
 
-                        ; Make palette (use VGA palette?)
-                     ;   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
+                ldx #0
 @lp:
-                                               .repeat 16
-                        lda colors,x
-                        sta     VCE_DATA_LO
-                        lda colors+1,x
-                        sta     VCE_DATA_HI
-                                               .endrepeat
-
-                                               inx
-                                               inx
-                                               cpx #16*2;*5
-                                               jne @lp
-
-                        stz     VCE_ADDR_LO
-                        stz     VCE_ADDR_HI
-                        stz     VCE_DATA_LO
-                        stz     VCE_DATA_HI
-
-; so it will get linked in
+                .repeat 16
+                lda colors,x
+                sta     VCE_DATA_LO
+                lda colors+1,x
+                sta     VCE_DATA_HI
+                .endrepeat
+
+                inx
+                inx
+                cpx #16*2
+                jne @lp
+
+                stz     VCE_ADDR_LO
+                stz     VCE_ADDR_HI
+                stz     VCE_DATA_LO
+                stz     VCE_DATA_HI
+
+                ; so it will get linked in
 _conio_init:
-                        rts
+                rts
 
 ;----------------------------------------------------------------------------
 ;
 ;----------------------------------------------------------------------------
 
-                        .importzp ptr1
-
+                .importzp ptr1
 conio_init:
-
-                        ; Load font
-                        st0     #VDC_MAWR
-                        st1     #<$2000
-                        st2     #>$2000
-
-                        ; ptr to font data
-                        lda    #<font
-                        sta            ptr1
-                        lda    #>font
-                        sta            ptr1+1
-
-                        st0     #VDC_VWR            ; VWR
-                        ldy     #$80            ; 128 chars
-        charloop:       ldx     #$08            ; 8 bytes/char
-        lineloop:
-                                               ;;lda     [$00]           ; read font byte
-                        lda (ptr1)
-                        staio  VDC_DATA_LO       ; bitplane 0
-                        stzio  VDC_DATA_HI       ; bitplane 1
-
-                        clc                     ; increment font pointer
-                        lda     ptr1
-                        adc     #$01
-                        sta     ptr1
-                        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
-
-                        .rodata
-font:                   .include "vga.inc"
+                ; Load font
+                st0     #VDC_MAWR
+                st1     #<$2000
+                st2     #>$2000
+
+                ; ptr to font data
+                lda    #<font
+                sta            ptr1
+                lda    #>font
+                sta            ptr1+1
+
+                st0     #VDC_VWR            ; VWR
+                ldy     #$80            ; 128 chars
+charloop:       ldx     #$08            ; 8 bytes/char
+lineloop:
+                lda (ptr1)
+                staio  VDC_DATA_LO       ; bitplane 0
+                stzio  VDC_DATA_HI       ; bitplane 1
+
+                clc                     ; increment font pointer
+                lda     ptr1
+                adc     #$01
+                sta     ptr1
+                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
+
+                .rodata
+font:
+                .include "vga.inc"
index 8a02a34998841c83e860bb9b77075b445cd43825..ec63b7565b52f3810911b73023de2278f31d7eb8 100644 (file)
@@ -1,81 +1,59 @@
 ;
-; Ullrich von Bassewitz, 06.08.1998
-;
 ; 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
-
-               .importzp tmp3,tmp4
-
-       .include        "pcengine.inc"
+                .export _cputcxy, _cputc, cputdirect, putchar
+                .export newline, plot
+                .import popa, _gotoxy
+                .import PLOT
 
+                .importzp tmp3,tmp4
 
+                .include        "pce.inc"
 _cputcxy:
-       pha                     ; Save C
-       jsr     popa            ; Get Y
-       jsr     _gotoxy         ; Set cursor, drop x
-       pla                     ; Restore C
+                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
+_cputc:         cmp     #$0d            ; CR?
+                bne     L1
+                lda     #0
+                sta     CURS_X
+                beq     plot            ; Recalculate pointers
 
-L1:    cmp     #$0a            ; LF?
-               beq     newline         ; Recalculate pointers
+L1:             cmp     #$0a            ; LF?
+                beq     newline         ; Recalculate pointers
 
 ; Printable char of some sort
 
 cputdirect:
-       jsr     putchar         ; Write the character to the screen
+                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
-       ;rts
+                ldy     CURS_X
+                iny
+                cpy     #xsize
+                bne     L3
+                jsr     newline         ; new line
+                ldy     #0              ; + cr
+L3:             sty     CURS_X
+                jmp     plot
 
 newline:
-;      lda     #xsize
-;      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
+                inc     CURS_Y
 
 ; Set cursor position, calculate RAM pointers
 
-plot:  ldy     CURS_X
-               ldx     CURS_Y
-               clc
-               jmp     PLOT            ; Set the new cursor
+plot:           ldy     CURS_X
+                ldx     CURS_Y
+                clc
+                jmp     PLOT            ; Set the new cursor
 
 
 
@@ -84,34 +62,32 @@ plot:       ldy     CURS_X
 
 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
+                staio   VDC_DATA_LO
 
-               lda SCREEN_PTR
-               staio VDC_DATA_LO
+                lda     SCREEN_PTR+1
+                staio   VDC_DATA_HI
 
-               lda SCREEN_PTR+1
-               staio VDC_DATA_HI
+                st0     #VDC_VWR        ; VWR
 
-               st0     #VDC_VWR    ; VWR
+                txa
+                staio   VDC_DATA_LO     ; character
 
-               txa
-               staio VDC_DATA_LO   ; character
+                lda   CHARCOLOR
 
-               ;;st2     #$32      ; attrib ?!
-               lda   CHARCOLOR
-               
-               ;;lda #2
-               asl a
-               asl a
-               asl a
-               asl a
+                asl a
+                asl a
+                asl a
+                asl a
 
-               and #$f0
-        ora   #$02
-               staio VDC_DATA_HI
+                and #$f0
+                ora   #$02
+                staio VDC_DATA_HI
 
-        rts
+                rts
index c6c0dabb87ff0795a4bc54315d67c2ed4ecc3712..06454998b0a5fa166dbb838af2a6ace78edfebed 100644 (file)
@@ -24,7 +24,7 @@
        .import         __DATA_LOAD__,__DATA_RUN__, __DATA_SIZE__       ; Linker generated
        .import __BSS_SIZE__
 
-       .include "pcengine.inc"
+       .include "pce.inc"
 
     .importzp       sp
        .importzp       ptr1,ptr2
@@ -84,10 +84,9 @@ start:
                 sta     IRQ_MASK     ; Interrupts off
                 stz     IRQ_STATUS   ; Acknowledge timer
 
-                ;; i dont know why the heck this one doesnt
-                ;; work when called from a constructor :/
-                        .import vdc_init
-                        jsr     vdc_init
+                ;; FIXME; i dont know why the heck this one doesnt work when called from a constructor :/
+                .import vdc_init
+                jsr     vdc_init
 
 ;;                        jsr     joy_init
 
@@ -167,6 +166,7 @@ start:
 
                jsr     initlib
 
+               ;; FIXME: this should be called from a constructor instead
                .import initconio
                jsr initconio
 
diff --git a/libsrc/pce/ctype.s b/libsrc/pce/ctype.s
new file mode 100644 (file)
index 0000000..fa9a65c
--- /dev/null
@@ -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
+
+
index cfb59efe2f948db94237cd2919c5540682fd74b6..24f917cd68198b45f28300c3da9ee5647db40657 100644 (file)
@@ -1,19 +1,16 @@
 ;
-; Ullrich von Bassewitz, 06.08.1998
-;
 ; void gotoxy (unsigned char x, unsigned char y);
 ;
 
-       .export         _gotoxy
-       .import         popa, plot
+                .export _gotoxy
+                .import popa, plot
 
-       .include "pcengine.inc"
+                .include "pce.inc"
 
 _gotoxy:
-
-       sta     CURS_Y          ; Set Y
-       jsr popa                ; Get X
-       sta     CURS_X          ; Set X
-       jmp     plot            ; Set the cursor position
+                sta     CURS_Y          ; Set Y
+                jsr     popa            ; Get X
+                sta     CURS_X          ; Set X
+                jmp     plot            ; Set the cursor position
 
 
diff --git a/libsrc/pce/joy/pce-stdjoy.s b/libsrc/pce/joy/pce-stdjoy.s
new file mode 100644 (file)
index 0000000..6bc6bdf
--- /dev/null
@@ -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
+
diff --git a/libsrc/pce/joy_stat_stddrv.s b/libsrc/pce/joy_stat_stddrv.s
new file mode 100644 (file)
index 0000000..3972569
--- /dev/null
@@ -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
diff --git a/libsrc/pce/joy_stddrv.s b/libsrc/pce/joy_stddrv.s
new file mode 100644 (file)
index 0000000..e0ed695
--- /dev/null
@@ -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"
diff --git a/libsrc/pce/joytokbd.s b/libsrc/pce/joytokbd.s
deleted file mode 100644 (file)
index 1e8258e..0000000
+++ /dev/null
@@ -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
-
index f050d78ef94158ebfa7a2dd7da7a772ab8cdacf7..beb151a7b498d30adff67a212a014a0befc9f6d2 100644 (file)
@@ -1,41 +1,32 @@
 
-       .export PLOT
+                .export PLOT
 
-       .include        "pcengine.inc"
+                .include        "pce.inc"
 
 PLOT:
+                bcs @getpos
 
-       bcs @getpos
-
-       tya
-       clc
-       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
+                tya
+                clc
+                adc     _plotlo,x
+                sta     SCREEN_PTR
 
+                lda     _plothi,x
+                adc     #0
+                sta     SCREEN_PTR+1
 @getpos:
-       ldx CURS_Y
-       ldy CURS_X
-       rts
+                ldx CURS_Y
+                ldy CURS_X
+                rts
 
 _plotlo:
-       .repeat screenrows,line
-       .byte <($0000+(line*$80))
-       .endrepeat
+                .repeat screenrows,line
+                    .byte <($0000+(line*$80))
+                .endrepeat
 
 _plothi:
-       .repeat screenrows,line
-       .byte >($0000+(line*$80))
-       .endrepeat
+                .repeat screenrows,line
+                    .byte >($0000+(line*$80))
+                .endrepeat
 
 
diff --git a/libsrc/pce/libref.s b/libsrc/pce/libref.s
new file mode 100644 (file)
index 0000000..e4afa7e
--- /dev/null
@@ -0,0 +1,8 @@
+;
+; Oliver Schmidt, 2013-05-31
+;
+
+        .export         joy_libref
+        .import         _exit
+
+joy_libref      := _exit
diff --git a/libsrc/pce/pce-stdjoy.s b/libsrc/pce/pce-stdjoy.s
deleted file mode 100644 (file)
index 60c77db..0000000
+++ /dev/null
@@ -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
-
diff --git a/libsrc/pce/pcengine.inc b/libsrc/pce/pcengine.inc
deleted file mode 100644 (file)
index a0ef03f..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-
-; Write VDC register
-                  .macro VREG arg1,arg2
-                        st0     #arg1
-                        st1     #<(arg2)
-                        st2     #>(arg2)
-                  .endmacro
-
-_tickcount= $20
-
-screenrows = (224/8)
-charsperline = (512/8)
-xsize = charsperline
-
-CH_HLINE = 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)
-
-VDC_MAWR = 0 ; Memory Address Write Register
-VDC_MARR = 1 ; Memory Address Read Register
-VDC_VWR  = 2 ; VRAM Write Register
-VDC_VRR  = 3 ; VRAM Read Register
-VDC_CR   = 4 ; Control Register
-VDC_RCR  = 5 ; Raster Counter Register
-VDC_BXR  = 6 ; Background X-Scroll Register
-VDC_BYR  = 7 ; Background Y-Scroll Register
-VDC_MWR  = 8 ; Memory-access Width Register
-VDC_HSR  = 9 ; Horizontal Sync Register (?)
-VDC_HDR  =10 ; Horizontal Display Register (?)
-VDC_VPR  =11 ; (unknown)
-VDC_VDW  =12 ; (unknown use)
-VDC_VCR  =13 ; (unknown use)
-VDC_DCR  =14 ; (DMA) Control Register
-VDC_SOUR =15 ; (DMA) Source Register
-VDC_DESR =16 ; (DMA) Destination Register
-VDC_LENR =17 ; (DMA) Length Register
-VDC_SATB =18 ; Sprite Attribute Table
-
-VDC_CTRL       = $0000
-VDC_DATA_LO = $0002
-VDC_DATA_HI = $0003
-
-; huc6260 - Video Color Encoder (vce)
-
-; The DAC has a palette of 512 colours.
-; bitmap of the palette data is this: 0000000gggrrrbbb.
-; You can read and write the DAC-registers.
-
-VCE_CTRL = $0400    ; write$00 to reset
-VCE_ADDR_LO = $0402 ; LSB of byte offset into palette
-VCE_ADDR_HI = $0403 ; MSB of byte offset into palette
-VCE_DATA_LO = $0404 ; LSB of 16-bit palette data
-VCE_DATA_HI = $0405 ; MSB of 16-bit palette data
-
-TIMER_COUNT = $0c00
-TIMER_CTRL     = $0c01
-
-JOY_CTRL       = $1000
-
-IRQ_MASK       = $1402
-IRQ_STATUS     = $1403
-
-CDR_MEM_DISABLE = $1803
-CDR_MEM_ENABLE  = $1807
-
-
-;; lda abs
-.macro ldaio arg1
-        .byte $ad
-        .word arg1
-.endmacro
-;; sta abs
-.macro staio arg1
-        .byte $8d
-        .word arg1
-.endmacro
-;; stz abs
-.macro stzio arg1
-        .byte $9c
-        .word arg1
-.endmacro
index ebf35d952e3a163589564f52dd947ea1760f1ba4..431f5883445461738a1bf3a1648d04020d88a464 100644 (file)
@@ -1,29 +1,29 @@
-                         
-                                               .include "pcengine.inc"
 
-            .export psg_init
+                .include "pce.inc"
+
+                .export psg_init
 
 psg_init:
-                        clx
-                        stx     $0800   ; Select channel
+                clx
+                stx     $0800   ; Select channel
 psg_clear_loop:
-                        stz     $0801   ; Clear global balance
-                        stz     $0802   ; Clear frequency LSB
-                        stz     $0803   ; Clear frequency MSB
-                        stz     $0804   ; Clear volume
-                        stz     $0805   ; Clear balance
-                        stz     $0807   ; Clear noise control
-                        stz     $0808   ; Clear LFO frequency
-                        stz     $0809   ; Clear LFO control
+                stz     $0801   ; Clear global balance
+                stz     $0802   ; Clear frequency LSB
+                stz     $0803   ; Clear frequency MSB
+                stz     $0804   ; Clear volume
+                stz     $0805   ; Clear balance
+                stz     $0807   ; Clear noise control
+                stz     $0808   ; Clear LFO frequency
+                stz     $0809   ; Clear LFO control
 
-                        cly
+                cly
 psg_clear_waveform:     stz     $0806   ; Clear waveform byte
-                        iny
-                        cpy     #$20
-                        bne     psg_clear_waveform
+                iny
+                cpy     #$20
+                bne     psg_clear_waveform
+
+                inx
+                cpx     #$06
+                bne     psg_clear_loop
+                rts
 
-                        inx
-                        cpx     #$06
-                        bne     psg_clear_loop
-                        rts
-                          
diff --git a/libsrc/pce/readme.txt b/libsrc/pce/readme.txt
new file mode 100644 (file)
index 0000000..e99b551
--- /dev/null
@@ -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
index d1358a52be188937af71f2c858cf46c0d1d5e0d6..c39a9f8439b458d30789983e955be3bdcea314aa 100644 (file)
@@ -1,5 +1,5 @@
 
-    .export _revers
+            .export _revers
 _revers:
-    lda #0
-    rts     
+            lda #0
+            rts
index 1f96c062c175f089c1b20fb4d38abd8e19cf742b..461fd1e755d0846c762e5ba16beb0b0ca72034a6 100644 (file)
@@ -1,5 +1,5 @@
 
-                        .include "pcengine.inc"
+                        .include "pce.inc"
 
                         .export vce_init
 
index 47efdff55091b5dd8c5fe26d55a9acb21ffb2191..d1ead937e3e2c8c2dbdc42f422753897c62809e3 100644 (file)
@@ -1,5 +1,5 @@
 
-                        .include "pcengine.inc"
+                        .include "pce.inc"
 
 HIRES = 1
 
diff --git a/testcode/lib/conio.c b/testcode/lib/conio.c
deleted file mode 100644 (file)
index 6a7bb23..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#include <conio.h>
-
-void main(void)
-{
-    clrscr();
-//    cprintf("hello world");
-    cputs("hello world");
-    for(;;);
-}
\ No newline at end of file
diff --git a/testcode/lib/pce/conio.c b/testcode/lib/pce/conio.c
new file mode 100644 (file)
index 0000000..306eb1e
--- /dev/null
@@ -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(;;);
+}
\ No newline at end of file