From 57b8af1adc21f5c9215559af16f134957743baf6 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Sat, 29 Aug 2015 15:58:57 +0200 Subject: [PATCH] style fixes --- README.md | 3 + asminc/pce.inc | 86 +++++----- include/pce.h | 30 ++-- libsrc/pce/_scrsize.s | 16 +- libsrc/pce/clock.s | 35 ++-- libsrc/pce/clrscr.s | 38 ++--- libsrc/pce/color.s | 87 +++++----- libsrc/pce/conio.s | 184 ++++++++++----------- libsrc/pce/cputc.s | 107 +++++++------ libsrc/pce/crt0.s | 300 ++++++++++++++++++----------------- libsrc/pce/gotoxy.s | 18 +-- libsrc/pce/joy/pce-stdjoy.s | 128 +++++++-------- libsrc/pce/joy_stat_stddrv.s | 6 +- libsrc/pce/joy_stddrv.s | 2 +- libsrc/pce/kplot.s | 43 +++-- libsrc/pce/psg.s | 44 ++--- libsrc/pce/revers.s | 32 ++-- libsrc/pce/vce.s | 29 ++-- libsrc/pce/vdc.s | 53 ++++--- libsrc/pce/vga.inc | 257 +++++++++++++++--------------- libsrc/pce/waitvblank.s | 10 +- testcode/lib/pce/conio.c | 212 ++++++++++++------------- 22 files changed, 866 insertions(+), 854 deletions(-) diff --git a/README.md b/README.md index 660798128..c93a6f920 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ [![build status](http://travis-ci.org/cc65/cc65.png)](http://travis-ci.org/cc65/cc65/builds) +Binary snapshot for [Windows](http://sourceforge.net/projects/cc65/files/cc65-snapshot-win32.zip) + cc65 is a complete cross development package for 65(C)02 systems, including a powerful macro assembler, a C compiler, linker, librarian and several other tools. @@ -23,6 +25,7 @@ including - the Atari 8 bit machines. - the Atari 5200 console. - GEOS for the C64, C128 and Apple //e. +- the NEC PC-Engine - the Nintendo Entertainment System (NES) console. - the Supervision console. - the Oric Atmos. diff --git a/asminc/pce.inc b/asminc/pce.inc index 4680ba826..2d2843143 100644 --- a/asminc/pce.inc +++ b/asminc/pce.inc @@ -2,44 +2,44 @@ ; 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 ;4 - -screenrows = (224/8) -charsperline = 61 - -CH_HLINE = 1 -CH_VLINE = 2 +; 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 ;4 + +; FIXME: screen dimensions my change according to selected video mode +screenrows = (224/8) +charsperline = 61 + +CH_HLINE = 1 +CH_VLINE = 2 ; 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_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 port ; Note: absolute addressing mode must be used when writing to this port @@ -54,21 +54,21 @@ VDC_DATA_HI = $0003 ; bitmap of the palette data is this: 0000000gggrrrbbb. ; You can read and write the DAC-registers. -VCE = $0400 ; base +VCE = $0400 ; base -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 +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 ; programmable sound generator (PSG) -PSG = $0800 ; base +PSG = $0800 ; base ; timer -TIMER = $0c00 ; base +TIMER = $0c00 ; base TIMER_COUNT = $0c00 TIMER_CTRL = $0c01 diff --git a/include/pce.h b/include/pce.h index 6f18ba501..7700654c8 100644 --- a/include/pce.h +++ b/include/pce.h @@ -36,20 +36,20 @@ # error This module may only be used when compiling for the PCE! #endif -#define CH_HLINE 1 -#define CH_VLINE 2 -#define CH_CROSS 3 -#define CH_ULCORNER 4 -#define CH_URCORNER 5 -#define CH_LLCORNER 6 -#define CH_LRCORNER 7 -#define CH_TTEE 8 -#define CH_BTEE 9 -#define CH_LTEE 10 -#define CH_RTEE 11 +#define CH_HLINE 1 +#define CH_VLINE 2 +#define CH_CROSS 3 +#define CH_ULCORNER 4 +#define CH_URCORNER 5 +#define CH_LLCORNER 6 +#define CH_LRCORNER 7 +#define CH_TTEE 8 +#define CH_BTEE 9 +#define CH_LTEE 10 +#define CH_RTEE 11 -#define CH_ENTER 13 -#define CH_PI 18 +#define CH_ENTER 13 +#define CH_PI 18 /* Color defines (CBM compatible, for conio) */ #define COLOR_BLACK 0x00 @@ -77,7 +77,7 @@ #define DYN_DRV 0 /* The addresses of the static drivers */ -extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ +extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */ #define JOY_FIRE_B 5 #define JOY_SELECT 6 @@ -87,7 +87,7 @@ void waitvblank (void); /* Wait for the vertical blanking */ /* NOTE: all PCE are NTSC */ -#define get_tv() TV_NTSC +#define get_tv() TV_NTSC /* Return the video mode the machine is using. */ /* End of pce.h */ diff --git a/libsrc/pce/_scrsize.s b/libsrc/pce/_scrsize.s index 8dab2cf7b..038622a6f 100644 --- a/libsrc/pce/_scrsize.s +++ b/libsrc/pce/_scrsize.s @@ -1,18 +1,18 @@ ; ; Screen size variables ; - .include "pce.inc" + .include "pce.inc" - .export screensize + .export screensize screensize: - ldx xsize - ldy ysize - rts + ldx xsize + ldy ysize + rts ; FIXME: changing the video mode allows for different screen sizes .rodata - .export xsize, ysize + .export xsize, ysize -xsize: .byte charsperline -ysize: .byte screenrows +xsize: .byte charsperline +ysize: .byte screenrows diff --git a/libsrc/pce/clock.s b/libsrc/pce/clock.s index 5d0aa78f4..6b14232fe 100644 --- a/libsrc/pce/clock.s +++ b/libsrc/pce/clock.s @@ -2,30 +2,29 @@ ; clock_t clock (void); ; - .include "pce.inc" + .include "pce.inc" - .export _clock - .importzp sreg -;; .importzp tickcount + .export _clock + .importzp sreg .proc _clock - lda tickcount+3 - sta sreg+1 - lda tickcount+2 - sta sreg - ldx tickcount+1 - lda tickcount - rts + lda tickcount+3 + sta sreg+1 + lda tickcount+2 + sta sreg + ldx tickcount+1 + lda tickcount + rts .endproc - .constructor initclock, 24 + .constructor initclock, 24 initclock: - lda #0 - ldx #3 -@lp: sta tickcount,x - dex - bpl @lp - rts \ No newline at end of file + lda #0 + ldx #3 +@lp: sta tickcount,x + dex + bpl @lp + rts diff --git a/libsrc/pce/clrscr.s b/libsrc/pce/clrscr.s index 9279f1e25..eae2b27a2 100644 --- a/libsrc/pce/clrscr.s +++ b/libsrc/pce/clrscr.s @@ -1,30 +1,32 @@ - .include "pce.inc" + .include "pce.inc" - .export _clrscr + .export _clrscr _clrscr: - st0 #VDC_MAWR - st1 #<$0000 - st2 #>$0000 + st0 #VDC_MAWR + st1 #<$0000 + st2 #>$0000 - st0 #VDC_VWR - ldy #$40 -rowloop: ldx #$80 -colloop: lda #' ' - sta a:VDC_DATA_LO - lda #$02 - sta a:VDC_DATA_HI + st0 #VDC_VWR + ldy #$40 +rowloop: + ldx #$80 +colloop: + lda #' ' + sta a:VDC_DATA_LO + lda #$02 + sta a:VDC_DATA_HI - dex - bne colloop - dey - bne rowloop + dex + bne colloop + dey + bne rowloop - rts + rts ;------------------------------------------------------------------------------- ; force the init constructor to be imported .import initconio -conio_init = initconio +conio_init = initconio diff --git a/libsrc/pce/color.s b/libsrc/pce/color.s index 03d93b186..36c85b6b5 100644 --- a/libsrc/pce/color.s +++ b/libsrc/pce/color.s @@ -5,59 +5,60 @@ ; - .export _textcolor, _bgcolor, _bordercolor + .export _textcolor, _bgcolor, _bordercolor - .include "pce.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 ;------------------------------------------------------------------------------- ; force the init constructor to be imported - .import initconio -conio_init = initconio + .import initconio +conio_init = initconio diff --git a/libsrc/pce/conio.s b/libsrc/pce/conio.s index 4fb3b1394..b9333e1fa 100644 --- a/libsrc/pce/conio.s +++ b/libsrc/pce/conio.s @@ -1,121 +1,123 @@ - .include "pce.inc" + .include "pce.inc" - .import vce_init - .import psg_init - .import vdc_init + .import vce_init + .import psg_init + .import vdc_init - .constructor initconio, 24 + .constructor initconio, 24 + + .macpack longbranch - .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 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 + stz VCE_ADDR_LO + stz VCE_ADDR_HI - ldx #0 + ldx #0 @lp: - ldy #16 + ldy #16 @lp1: - lda colors,x - sta VCE_DATA_LO - lda colors+1,x - sta VCE_DATA_HI - dey - bne @lp1 + lda colors,x + sta VCE_DATA_LO + lda colors+1,x + sta VCE_DATA_HI + dey + bne @lp1 - inx - inx - cpx #16*2 - jne @lp + inx + inx + cpx #16*2 + jne @lp - stz VCE_ADDR_LO - stz VCE_ADDR_HI - stz VCE_DATA_LO - stz VCE_DATA_HI + stz VCE_ADDR_LO + stz VCE_ADDR_HI + stz VCE_DATA_LO + stz VCE_DATA_HI - rts + rts ;---------------------------------------------------------------------------- ; ;---------------------------------------------------------------------------- - .importzp ptr1, tmp1 + .importzp ptr1, tmp1 conio_init: - ; Load font - st0 #VDC_MAWR - st1 #<$2000 - st2 #>$2000 + ; Load font + st0 #VDC_MAWR + st1 #<$2000 + st2 #>$2000 - ; ptr to font data - lda #font - sta ptr1+1 + ; ptr to font data + lda #font + sta ptr1+1 - st0 #VDC_VWR ; VWR + st0 #VDC_VWR ; VWR - lda #0 - sta tmp1 - jsr copy + lda #0 + sta tmp1 + jsr copy - lda #font - sta ptr1+1 + lda #font + sta ptr1+1 - lda #$ff - sta tmp1 - jsr copy + lda #$ff + sta tmp1 + jsr copy - ldx #0 - stx BGCOLOR - inx - stx CHARCOLOR + ldx #0 + stx BGCOLOR + inx + stx CHARCOLOR - rts + rts copy: - ldy #$80 ; 128 chars -charloop: ldx #$08 ; 8 bytes/char + ldy #$80 ; 128 chars +charloop: + ldx #$08 ; 8 bytes/char lineloop: - lda (ptr1) - eor tmp1 - sta a:VDC_DATA_LO ; bitplane 0 - stz a: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 - - rts - - .rodata + lda (ptr1) + eor tmp1 + sta a:VDC_DATA_LO ; bitplane 0 + stz a: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 + + rts + + .rodata font: - .include "vga.inc" + .include "vga.inc" diff --git a/libsrc/pce/cputc.s b/libsrc/pce/cputc.s index 918f39e29..d31e13769 100644 --- a/libsrc/pce/cputc.s +++ b/libsrc/pce/cputc.s @@ -3,97 +3,96 @@ ; void cputc (char c); ; - .export _cputcxy, _cputc, cputdirect, putchar - .export newline, plot - .import popa, _gotoxy - .import PLOT - .import xsize + .export _cputcxy, _cputc, cputdirect, putchar + .export newline, plot + .import popa, _gotoxy + .import PLOT + .import xsize - .importzp tmp3,tmp4 + .importzp tmp3,tmp4 + + .include "pce.inc" - .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 + ldy CURS_X + iny + cpy xsize + bne L3 + jsr newline ; new line + ldy #0 ; + cr +L3: sty CURS_X + jmp plot newline: - inc CURS_Y + 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 ; Write one character to the screen without doing anything else, return X ; position in Y 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 - sta a:VDC_DATA_LO + lda SCREEN_PTR + sta a:VDC_DATA_LO - lda SCREEN_PTR+1 - sta a:VDC_DATA_HI + lda SCREEN_PTR + 1 + sta a:VDC_DATA_HI - st0 #VDC_VWR ; VWR + st0 #VDC_VWR ; VWR - txa - sta a:VDC_DATA_LO ; character + txa + sta a:VDC_DATA_LO ; character - lda CHARCOLOR + lda CHARCOLOR - asl a - asl a - asl a - asl a + asl a + asl a + asl a + asl a - ora #$02 - sta a:VDC_DATA_HI + ora #$02 + sta a:VDC_DATA_HI - rts + rts ;------------------------------------------------------------------------------- ; force the init constructor to be imported - .import initconio -conio_init = initconio + .import initconio +conio_init = initconio diff --git a/libsrc/pce/crt0.s b/libsrc/pce/crt0.s index 2b8455a59..f89119c46 100644 --- a/libsrc/pce/crt0.s +++ b/libsrc/pce/crt0.s @@ -7,153 +7,155 @@ ; This must be the *first* file on the linker command line ; - .export _exit - .export __STARTUP__ : absolute = 1 ; Mark as startup + .export _exit + .export __STARTUP__ : absolute = 1 ; Mark as startup - .import initlib, donelib - .import push0, _main, zerobss - .import initheap - .import tmp1,tmp2,tmp3 + .import initlib, donelib + .import push0, _main, zerobss + .import initheap + .import tmp1,tmp2,tmp3 ; Linker generated - .import __RAM_START__, __RAM_SIZE__ - .import __ROM0_START__, __ROM0_SIZE__ - .import __ROM_START__, __ROM_SIZE__ - .import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__ - .import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__ - .import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__ - .import __DATA_LOAD__,__DATA_RUN__, __DATA_SIZE__ - .import __BSS_SIZE__ + .import __RAM_START__, __RAM_SIZE__ + .import __ROM0_START__, __ROM0_SIZE__ + .import __ROM_START__, __ROM_SIZE__ + .import __STARTUP_LOAD__,__STARTUP_RUN__, __STARTUP_SIZE__ + .import __CODE_LOAD__,__CODE_RUN__, __CODE_SIZE__ + .import __RODATA_LOAD__,__RODATA_RUN__, __RODATA_SIZE__ + .import __DATA_LOAD__,__DATA_RUN__, __DATA_SIZE__ + .import __BSS_SIZE__ - .include "pce.inc" + .include "pce.inc" - .importzp sp - .importzp ptr1,ptr2 + .importzp sp + .importzp ptr1,ptr2 ; ------------------------------------------------------------------------ ; Place the startup code in a special segment. - .segment "STARTUP" + .segment "STARTUP" start: - ; setup the CPU and System-IRQ - - ; Initialize CPU - - sei - nop - csh ; set high speed CPU mode - nop - cld - nop - - ; Setup stack and memory mapping - ldx #$FF ; Stack top ($21FF) - txs - - ; at startup all MPRs are set to 0, so init them - lda #$ff - tam #%00000001 ; 0000-1FFF = Hardware page - lda #$F8 - tam #%00000010 ; 2000-3FFF = Work RAM - ;lda #$F7 - ;tam #%00000100 ; 4000-5FFF = Save RAM - ;lda #1 - ;tam #%00001000 ; 6000-7FFF Page 2 - ;lda #2 - ;tam #%00010000 ; 8000-9FFF Page 3 - ;lda #3 - ;tam #%00100000 ; A000-BFFF Page 4 - ;lda #4 - ;tam #%01000000 ; C000-DFFF Page 5 - ;lda #0 - ;tam #%10000000 ; e000-fFFF hucard/syscard bank 0 - - ; Clear work RAM (2000-3FFF) - stz <$00 - tii $2000, $2001, $1FFF - - ; Initialize hardware - stz TIMER_COUNT ; Timer off - lda #$07 - sta IRQ_MASK ; Interrupts off - stz IRQ_STATUS ; Acknowledge timer - - ;; FIXME; i dont know why the heck this one doesnt work when called from a constructor :/ - .import vdc_init - jsr vdc_init - - ; Turn on background and VD interrupt/IRQ1 - lda #$05 - sta IRQ_MASK ; IRQ1=on - - ; Clear the BSS data - jsr zerobss - - ; Copy the .data segment to RAM - lda #<(__DATA_LOAD__) - sta ptr1 - lda #>(__DATA_LOAD__) - sta ptr1+1 - lda #<(__DATA_RUN__) - sta ptr2 - lda #>(__DATA_RUN__) - sta ptr2+1 - - ldx #>(__DATA_SIZE__) + ; setup the CPU and System-IRQ + + ; Initialize CPU + + sei + nop + csh ; set high speed CPU mode + nop + cld + nop + + ; Setup stack and memory mapping + ldx #$FF ; Stack top ($21FF) + txs + + ; at startup all MPRs are set to 0, so init them + lda #$ff + tam #%00000001 ; 0000-1FFF = Hardware page + lda #$F8 + tam #%00000010 ; 2000-3FFF = Work RAM + + ; FIXME: setup a larger block of memory to use with C-code + ;lda #$F7 + ;tam #%00000100 ; 4000-5FFF = Save RAM + ;lda #1 + ;tam #%00001000 ; 6000-7FFF Page 2 + ;lda #2 + ;tam #%00010000 ; 8000-9FFF Page 3 + ;lda #3 + ;tam #%00100000 ; A000-BFFF Page 4 + ;lda #4 + ;tam #%01000000 ; C000-DFFF Page 5 + ;lda #0 + ;tam #%10000000 ; e000-fFFF hucard/syscard bank 0 + + ; Clear work RAM (2000-3FFF) + stz <$00 + tii $2000, $2001, $1FFF + + ; Initialize hardware + stz TIMER_COUNT ; Timer off + lda #$07 + sta IRQ_MASK ; Interrupts off + stz IRQ_STATUS ; Acknowledge timer + + ; FIXME; i dont know why the heck this one doesnt work when called from a constructor :/ + .import vdc_init + jsr vdc_init + + ; Turn on background and VD interrupt/IRQ1 + lda #$05 + sta IRQ_MASK ; IRQ1=on + + ; Clear the BSS data + jsr zerobss + + ; Copy the .data segment to RAM + lda #<(__DATA_LOAD__) + sta ptr1 + lda #>(__DATA_LOAD__) + sta ptr1+1 + lda #<(__DATA_RUN__) + sta ptr2 + lda #>(__DATA_RUN__) + sta ptr2+1 + + ldx #>(__DATA_SIZE__) @l2: - beq @s1 ; no more full pages + beq @s1 ; no more full pages - ; copy one page - ldy #0 + ; copy one page + ldy #0 @l1: - lda (ptr1),y - sta (ptr2),y - iny - bne @l1 + lda (ptr1),y + sta (ptr2),y + iny + bne @l1 - inc ptr1+1 - inc ptr2+1 + inc ptr1+1 + inc ptr2+1 - dex - bne @l2 + dex + bne @l2 - ; copy remaining bytes + ; copy remaining bytes @s1: - ; copy one page - ldy #0 + ; copy one page + ldy #0 @l3: - lda (ptr1),y - sta (ptr2),y - iny - cpy #<(__DATA_SIZE__) - bne @l3 + lda (ptr1),y + sta (ptr2),y + iny + cpy #<(__DATA_SIZE__) + bne @l3 - ; setup the stack - lda #<(__RAM_START__+__RAM_SIZE__) - sta sp - lda #>(__RAM_START__+__RAM_SIZE__) - sta sp+1 + ; setup the stack + lda #<(__RAM_START__+__RAM_SIZE__) + sta sp + lda #>(__RAM_START__+__RAM_SIZE__) + sta sp + 1 - ; Call module constructors - jsr initlib + ; Call module constructors + jsr initlib - cli ; allow IRQ only after constructors have run + cli ; allow IRQ only after constructors have run - ; Pass an empty command line - jsr push0 ; argc - jsr push0 ; argv + ; Pass an empty command line + jsr push0 ; argc + jsr push0 ; argv - ldy #4 ; Argument size - jsr _main ; call the users code + ldy #4 ; Argument size + jsr _main ; call the users code - ; Call module destructors. This is also the _exit entry. + ; Call module destructors. This is also the _exit entry. _exit: - jsr donelib ; Run module destructors + jsr donelib ; Run module destructors - ; reset the PCEngine (start over) - jmp start + ; reset the PCEngine (start over) + jmp start ; ------------------------------------------------------------------------ ; System V-Blank Interupt @@ -161,45 +163,45 @@ _exit: ; ------------------------------------------------------------------------ _irq1: - pha - phx - phy - - - inc tickcount - bne @s1 - inc tickcount+1 - bne @s1 - inc tickcount+2 - bne @s1 - inc tickcount+3 + pha + phx + phy + + ; increment the system tick counter + inc tickcount + bne @s1 + inc tickcount + 1 + bne @s1 + inc tickcount + 2 + bne @s1 + inc tickcount + 3 @s1: - ; Acknowlege interrupt - lda a:VDC_CTRL + ; Acknowlege interrupt + lda a:VDC_CTRL - ply - plx - pla - rti + ply + plx + pla + rti _irq2: - rti + rti _nmi: - rti + rti _timer: - stz IRQ_STATUS - rti + stz IRQ_STATUS + rti - .export initmainargs + .export initmainargs initmainargs: - rts + rts ; ------------------------------------------------------------------------ ; hardware vectors ; ------------------------------------------------------------------------ - .segment "VECTORS" + .segment "VECTORS" - .word _irq2 ; $fff6 IRQ2 (External IRQ, BRK) - .word _irq1 ; $fff8 IRQ1 (VDC) - .word _timer ; $fffa Timer - .word _nmi ; $fffc NMI - .word start ; $fffe reset + .word _irq2 ; $fff6 IRQ2 (External IRQ, BRK) + .word _irq1 ; $fff8 IRQ1 (VDC) + .word _timer ; $fffa Timer + .word _nmi ; $fffc NMI + .word start ; $fffe reset diff --git a/libsrc/pce/gotoxy.s b/libsrc/pce/gotoxy.s index c6b937177..c7cda83f3 100644 --- a/libsrc/pce/gotoxy.s +++ b/libsrc/pce/gotoxy.s @@ -2,20 +2,20 @@ ; void gotoxy (unsigned char x, unsigned char y); ; - .export _gotoxy - .import popa, plot + .export _gotoxy + .import popa, plot - .include "pce.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 ;------------------------------------------------------------------------------- ; force the init constructor to be imported - .import initconio -conio_init = initconio + .import initconio +conio_init = initconio diff --git a/libsrc/pce/joy/pce-stdjoy.s b/libsrc/pce/joy/pce-stdjoy.s index 592793250..746929dd2 100644 --- a/libsrc/pce/joy/pce-stdjoy.s +++ b/libsrc/pce/joy/pce-stdjoy.s @@ -5,6 +5,7 @@ .include "joy-kernel.inc" .include "joy-error.inc" + .include "pce.inc" .macpack module @@ -58,10 +59,10 @@ JOY_COUNT = 4 ; Number of joysticks we support ; INSTALL: - lda #JOY_ERR_OK + lda #JOY_ERR_OK -; rts ; Run into DEINSTALL instead +; rts ; Run into UNINSTALL instead ; ------------------------------------------------------------------------ ; DEINSTALL routine. Is called before the driver is removed from memory. @@ -69,7 +70,7 @@ INSTALL: ; UNINSTALL: - rts + rts ; ------------------------------------------------------------------------ @@ -78,9 +79,9 @@ UNINSTALL: ;unsigned char __fastcall__ joy_count (void); COUNT: - lda #JOY_COUNT - rts + lda #JOY_COUNT + rts ; ------------------------------------------------------------------------ ; READ: Read a particular joystick passed in A. @@ -88,70 +89,71 @@ COUNT: ;unsigned char __fastcall__ joy_read (unsigned char joystick); READJOY: - pha - jsr read_joy - pla - tax ; Joystick number into X + pha + jsr read_joy + pla + tax ; Joystick number into X - ; return value from buffer + ; return value from buffer joy1: - lda padbuffer,x - ldx #0 - rts + 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 + ; reset multitap counter + lda #$01 + sta JOY_CTRL + pha + pla + nop + nop + + lda #$03 + sta JOY_CTRL + 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 + lda #$01 + sta JOY_CTRL ; sel = 1 + pha + pla + nop ; some delay is required + nop + + lda JOY_CTRL + asl a + asl a + asl a + asl a + sta padbuffer, y ; store new value + + stz JOY_CTRL + pha + pla + + nop ; some delay is required + nop + + lda JOY_CTRL + 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 + .res 4 diff --git a/libsrc/pce/joy_stat_stddrv.s b/libsrc/pce/joy_stat_stddrv.s index 3972569ed..2424c456b 100644 --- a/libsrc/pce/joy_stat_stddrv.s +++ b/libsrc/pce/joy_stat_stddrv.s @@ -6,9 +6,9 @@ ; const void joy_static_stddrv[]; ; - .export _joy_static_stddrv - .import _pce_stdjoy_joy + .export _joy_static_stddrv + .import _pce_stdjoy_joy .rodata -_joy_static_stddrv := _pce_stdjoy_joy +_joy_static_stddrv := _pce_stdjoy_joy diff --git a/libsrc/pce/joy_stddrv.s b/libsrc/pce/joy_stddrv.s index e0ed6957e..ba397409a 100644 --- a/libsrc/pce/joy_stddrv.s +++ b/libsrc/pce/joy_stddrv.s @@ -6,7 +6,7 @@ ; const char joy_stddrv[]; ; - .export _joy_stddrv + .export _joy_stddrv .rodata diff --git a/libsrc/pce/kplot.s b/libsrc/pce/kplot.s index eb4e79e04..b580f8473 100644 --- a/libsrc/pce/kplot.s +++ b/libsrc/pce/kplot.s @@ -1,37 +1,36 @@ - .export PLOT + .export PLOT - .include "pce.inc" + .include "pce.inc" PLOT: - bcs @getpos + bcs @getpos - tya - clc - adc _plotlo,x - sta SCREEN_PTR + tya + clc + adc _plotlo,x + sta SCREEN_PTR - lda _plothi,x - adc #0 - sta SCREEN_PTR+1 + 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 ;------------------------------------------------------------------------------- ; force the init constructor to be imported - .import initconio -conio_init = initconio - + .import initconio +conio_init = initconio diff --git a/libsrc/pce/psg.s b/libsrc/pce/psg.s index 431f58834..645c02615 100644 --- a/libsrc/pce/psg.s +++ b/libsrc/pce/psg.s @@ -1,29 +1,29 @@ - .include "pce.inc" + .include "pce.inc" - .export psg_init + .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 -psg_clear_waveform: stz $0806 ; Clear waveform byte - iny - cpy #$20 - bne psg_clear_waveform - - inx - cpx #$06 - bne psg_clear_loop - rts + cly +psg_clear_waveform: + stz $0806 ; Clear waveform byte + iny + cpy #$20 + bne psg_clear_waveform + inx + cpx #$06 + bne psg_clear_loop + rts diff --git a/libsrc/pce/revers.s b/libsrc/pce/revers.s index 061023d09..1773de2b0 100644 --- a/libsrc/pce/revers.s +++ b/libsrc/pce/revers.s @@ -1,27 +1,27 @@ - .include "pce.inc" + .include "pce.inc" - .export _revers + .export _revers .proc _revers - ldx #$00 ; Assume revers off - tay ; Test onoff - beq L1 ; Jump if off - ldx #$80 ; Load on value - ldy #$00 ; Assume old value is zero -L1: lda RVS ; Load old value - stx RVS ; Set new value - beq L2 ; Jump if old value zero - iny ; Make old value = 1 -L2: ldx #$00 ; Load high byte of result - tya ; Load low byte, set CC - rts + ldx #$00 ; Assume revers off + tay ; Test onoff + beq L1 ; Jump if off + ldx #$80 ; Load on value + ldy #$00 ; Assume old value is zero +L1: lda RVS ; Load old value + stx RVS ; Set new value + beq L2 ; Jump if old value zero + iny ; Make old value = 1 +L2: ldx #$00 ; Load high byte of result + tya ; Load low byte, set CC + rts .endproc ;------------------------------------------------------------------------------- ; force the init constructor to be imported - .import initconio -conio_init = initconio + .import initconio +conio_init = initconio diff --git a/libsrc/pce/vce.s b/libsrc/pce/vce.s index 461fd1e75..3c19fd55b 100644 --- a/libsrc/pce/vce.s +++ b/libsrc/pce/vce.s @@ -1,17 +1,20 @@ - .include "pce.inc" + .include "pce.inc" - .export vce_init + .export vce_init vce_init: - stz VCE_ADDR_LO ; - stz VCE_ADDR_HI ; Set CTA to zero - ldy #$01 -vce_clear_bank: ldx #$00 -vce_clear_color: stz VCE_DATA_LO ; Clear color (LSB) - stz VCE_DATA_HI ; Clear color (MSB) - dex - bne vce_clear_color - dey - bne vce_clear_bank - rts + ; Set CTA to zero + stz VCE_ADDR_LO + stz VCE_ADDR_HI + ldy #$01 +vce_clear_bank: + ldx #$00 +vce_clear_color: + stz VCE_DATA_LO ; Clear color (LSB) + stz VCE_DATA_HI ; Clear color (MSB) + dex + bne vce_clear_color + dey + bne vce_clear_bank + rts diff --git a/libsrc/pce/vdc.s b/libsrc/pce/vdc.s index 0f42fe1b0..878c79321 100644 --- a/libsrc/pce/vdc.s +++ b/libsrc/pce/vdc.s @@ -1,40 +1,41 @@ - .include "pce.inc" + .include "pce.inc" -HIRES = 1 +; FIXME: implement selection of different video modes at runtime +HIRES = 1 - .export vdc_init + .export vdc_init vdc_init: - lda a:VDC_CTRL - - VREG $00, $0000 ; MAWR - VREG $01, $0000 ; MARR - VREG $05, $0000 ; CR - VREG $06, $0000 ; RCR - VREG $07, $0000 ; BXR - VREG $08, $0000 ; BYR - VREG $09, $0070 ; MAWR - VREG $0C, $1702 ; CRTC - VSR - VREG $0D, $00DF ; CRTC - VDS - VREG $0E, $000C ; CRTC - VDE - VREG $0F, $0000 ; DCR + lda a:VDC_CTRL + + VREG $00, $0000 ; MAWR + VREG $01, $0000 ; MARR + VREG $05, $0000 ; CR + VREG $06, $0000 ; RCR + VREG $07, $0000 ; BXR + VREG $08, $0000 ; BYR + VREG $09, $0070 ; MAWR + VREG $0C, $1702 ; CRTC - VSR + VREG $0D, $00DF ; CRTC - VDS + VREG $0E, $000C ; CRTC - VDE + VREG $0F, $0000 ; DCR .if HIRES - VREG $0A, $0C02 ; CRTC - HSR - VREG $0B, $043C ; CRTC - HDS - lda #$06 - sta VCE_CTRL + VREG $0A, $0C02 ; CRTC - HSR + VREG $0B, $043C ; CRTC - HDS + lda #$06 + sta VCE_CTRL .else - VREG $0A, $0202 ; CRTC - HSR - VREG $0B, $041F ; CRTC - HDS - lda #$04 - sta VCE_CTRL + VREG $0A, $0202 ; CRTC - HSR + VREG $0B, $041F ; CRTC - HDS + lda #$04 + sta VCE_CTRL .endif - lda a:VDC_CTRL - rts + lda a:VDC_CTRL + rts diff --git a/libsrc/pce/vga.inc b/libsrc/pce/vga.inc index b5c4b27fd..9317d6ce4 100644 --- a/libsrc/pce/vga.inc +++ b/libsrc/pce/vga.inc @@ -1,8 +1,8 @@ ; VGA charset for the PC-Engine conio implementation - .byte $00, $00, $00, $00, $00, $00, $00, $00 - ;;.byte $7E, $81, $A5, $81, $BD, $99, $81, $7E + .byte $00, $00, $00, $00, $00, $00, $00, $00 + .byte %00000000 .byte %00000000 .byte %00000000 @@ -11,7 +11,7 @@ .byte %00000000 .byte %00000000 .byte %00000000 - ;;.byte $7E, $FF, $DB, $FF, $C3, $E7, $FF, $7E + .byte %00010000 .byte %00010000 .byte %00010000 @@ -20,7 +20,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 - ;;.byte $6C, $FE, $FE, $FE, $7C, $38, $10, $00 + .byte %00010000 .byte %00010000 .byte %00010000 @@ -29,7 +29,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 - ;;.byte $10, $38, $7C, $FE, $7C, $38, $10, $00 + .byte %00000000 .byte %00000000 .byte %00000000 @@ -38,7 +38,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 - ;;.byte $38, $7C, $38, $FE, $FE, $7C, $38, $7C + .byte %00000000 .byte %00000000 .byte %00000000 @@ -47,7 +47,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 - ;;.byte $10, $10, $38, $7C, $FE, $7C, $38, $7C + .byte %00010000 .byte %00010000 .byte %00010000 @@ -56,7 +56,7 @@ .byte %00000000 .byte %00000000 .byte %00000000 - ;;.byte $00, $00, $18, $3C, $3C, $18, $00, $00 + .byte %00010000 .byte %00010000 .byte %00010000 @@ -65,7 +65,7 @@ .byte %00000000 .byte %00000000 .byte %00000000 - ;;.byte $FF, $FF, $E7, $C3, $C3, $E7, $FF, $FF + .byte %00000000 .byte %00000000 .byte %00000000 @@ -74,7 +74,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 - ;;.byte $00, $3C, $66, $42, $42, $66, $3C, $00 + .byte %00010000 .byte %00010000 .byte %00010000 @@ -83,7 +83,7 @@ .byte %00000000 .byte %00000000 .byte %00000000 - ;;.byte $FF, $C3, $99, $BD, $BD, $99, $C3, $FF + .byte %00010000 .byte %00010000 .byte %00010000 @@ -92,7 +92,7 @@ .byte %00010000 .byte %00010000 .byte %00010000 - ;;.byte $0F, $07, $0F, $7D, $CC, $CC, $CC, $78 + .byte %00010000 .byte %00010000 .byte %00010000 @@ -101,119 +101,120 @@ .byte %00010000 .byte %00010000 .byte %00010000 - .byte $3C, $66, $66, $66, $3C, $18, $7E, $18 - .byte $3F, $33, $3F, $30, $30, $70, $F0, $E0 - .byte $7F, $63, $7F, $63, $63, $67, $E6, $C0 - .byte $99, $5A, $3C, $E7, $E7, $3C, $5A, $99 - .byte $80, $E0, $F8, $FE, $F8, $E0, $80, $00 - .byte $02, $0E, $3E, $FE, $3E, $0E, $02, $00 - .byte $18, $3C, $7E, $18, $18, $7E, $3C, $18 - .byte $66, $66, $66, $66, $66, $00, $66, $00 - .byte $7F, $DB, $DB, $7B, $1B, $1B, $1B, $00 - .byte $3E, $63, $38, $6C, $6C, $38, $CC, $78 - .byte $00, $00, $00, $00, $7E, $7E, $7E, $00 - .byte $18, $3C, $7E, $18, $7E, $3C, $18, $FF - .byte $18, $3C, $7E, $18, $18, $18, $18, $00 - .byte $18, $18, $18, $18, $7E, $3C, $18, $00 - .byte $00, $18, $0C, $FE, $0C, $18, $00, $00 - .byte $00, $30, $60, $FE, $60, $30, $00, $00 - .byte $00, $00, $C0, $C0, $C0, $FE, $00, $00 - .byte $00, $24, $66, $FF, $66, $24, $00, $00 - .byte $00, $18, $3C, $7E, $FF, $FF, $00, $00 - .byte $00, $FF, $FF, $7E, $3C, $18, $00, $00 - .byte $00, $00, $00, $00, $00, $00, $00, $00 - .byte $30, $78, $78, $78, $30, $00, $30, $00 - .byte $6C, $6C, $6C, $00, $00, $00, $00, $00 - .byte $6C, $6C, $FE, $6C, $FE, $6C, $6C, $00 - .byte $30, $7C, $C0, $78, $0C, $F8, $30, $00 - .byte $00, $C6, $CC, $18, $30, $66, $C6, $00 - .byte $38, $6C, $38, $76, $DC, $CC, $76, $00 - .byte $60, $60, $C0, $00, $00, $00, $00, $00 - .byte $18, $30, $60, $60, $60, $30, $18, $00 - .byte $60, $30, $18, $18, $18, $30, $60, $00 - .byte $00, $66, $3C, $FF, $3C, $66, $00, $00 - .byte $00, $30, $30, $FC, $30, $30, $00, $00 - .byte $00, $00, $00, $00, $00, $30, $30, $60 - .byte $00, $00, $00, $FC, $00, $00, $00, $00 - .byte $00, $00, $00, $00, $00, $30, $30, $00 - .byte $06, $0C, $18, $30, $60, $C0, $80, $00 - .byte $7C, $C6, $CE, $DE, $F6, $E6, $7C, $00 - .byte $30, $70, $30, $30, $30, $30, $FC, $00 - .byte $78, $CC, $0C, $38, $60, $CC, $FC, $00 - .byte $78, $CC, $0C, $38, $0C, $CC, $78, $00 - .byte $1C, $3C, $6C, $CC, $FE, $0C, $1E, $00 - .byte $FC, $C0, $F8, $0C, $0C, $CC, $78, $00 - .byte $38, $60, $C0, $F8, $CC, $CC, $78, $00 - .byte $FC, $CC, $0C, $18, $30, $30, $30, $00 - .byte $78, $CC, $CC, $78, $CC, $CC, $78, $00 - .byte $78, $CC, $CC, $7C, $0C, $18, $70, $00 - .byte $00, $30, $30, $00, $00, $30, $30, $00 - .byte $00, $30, $30, $00, $00, $30, $30, $60 - .byte $18, $30, $60, $C0, $60, $30, $18, $00 - .byte $00, $00, $FC, $00, $00, $FC, $00, $00 - .byte $60, $30, $18, $0C, $18, $30, $60, $00 - .byte $78, $CC, $0C, $18, $30, $00, $30, $00 - .byte $7C, $C6, $DE, $DE, $DE, $C0, $78, $00 - .byte $30, $78, $CC, $CC, $FC, $CC, $CC, $00 - .byte $FC, $66, $66, $7C, $66, $66, $FC, $00 - .byte $3C, $66, $C0, $C0, $C0, $66, $3C, $00 - .byte $F8, $6C, $66, $66, $66, $6C, $F8, $00 - .byte $7E, $60, $60, $78, $60, $60, $7E, $00 - .byte $7E, $60, $60, $78, $60, $60, $60, $00 - .byte $3C, $66, $C0, $C0, $CE, $66, $3E, $00 - .byte $CC, $CC, $CC, $FC, $CC, $CC, $CC, $00 - .byte $78, $30, $30, $30, $30, $30, $78, $00 - .byte $1E, $0C, $0C, $0C, $CC, $CC, $78, $00 - .byte $E6, $66, $6C, $78, $6C, $66, $E6, $00 - .byte $60, $60, $60, $60, $60, $60, $7E, $00 - .byte $C6, $EE, $FE, $FE, $D6, $C6, $C6, $00 - .byte $C6, $E6, $F6, $DE, $CE, $C6, $C6, $00 - .byte $38, $6C, $C6, $C6, $C6, $6C, $38, $00 - .byte $FC, $66, $66, $7C, $60, $60, $F0, $00 - .byte $78, $CC, $CC, $CC, $DC, $78, $1C, $00 - .byte $FC, $66, $66, $7C, $6C, $66, $E6, $00 - .byte $78, $CC, $E0, $70, $1C, $CC, $78, $00 - .byte $FC, $30, $30, $30, $30, $30, $30, $00 - .byte $CC, $CC, $CC, $CC, $CC, $CC, $FC, $00 - .byte $CC, $CC, $CC, $CC, $CC, $78, $30, $00 - .byte $C6, $C6, $C6, $D6, $FE, $EE, $C6, $00 - .byte $C6, $C6, $6C, $38, $38, $6C, $C6, $00 - .byte $CC, $CC, $CC, $78, $30, $30, $78, $00 - .byte $FE, $06, $0C, $18, $30, $60, $FE, $00 - .byte $78, $60, $60, $60, $60, $60, $78, $00 - .byte $C0, $60, $30, $18, $0C, $06, $02, $00 - .byte $78, $18, $18, $18, $18, $18, $78, $00 - .byte $10, $38, $6C, $C6, $00, $00, $00, $00 - .byte $00, $00, $00, $00, $00, $00, $00, $FF - .byte $30, $30, $18, $00, $00, $00, $00, $00 - .byte $00, $00, $78, $0C, $7C, $CC, $76, $00 - .byte $E0, $60, $60, $7C, $66, $66, $DC, $00 - .byte $00, $00, $78, $CC, $C0, $CC, $78, $00 - .byte $1C, $0C, $0C, $7C, $CC, $CC, $76, $00 - .byte $00, $00, $78, $CC, $FC, $C0, $78, $00 - .byte $38, $6C, $60, $F0, $60, $60, $F0, $00 - .byte $00, $00, $76, $CC, $CC, $7C, $0C, $F8 - .byte $E0, $60, $6C, $76, $66, $66, $E6, $00 - .byte $30, $00, $70, $30, $30, $30, $78, $00 - .byte $0C, $00, $0C, $0C, $0C, $CC, $CC, $78 - .byte $E0, $60, $66, $6C, $78, $6C, $E6, $00 - .byte $70, $30, $30, $30, $30, $30, $78, $00 - .byte $00, $00, $CC, $FE, $FE, $D6, $C6, $00 - .byte $00, $00, $F8, $CC, $CC, $CC, $CC, $00 - .byte $00, $00, $78, $CC, $CC, $CC, $78, $00 - .byte $00, $00, $DC, $66, $66, $7C, $60, $F0 - .byte $00, $00, $76, $CC, $CC, $7C, $0C, $1E - .byte $00, $00, $DC, $76, $66, $60, $F0, $00 - .byte $00, $00, $7C, $C0, $78, $0C, $F8, $00 - .byte $10, $30, $7C, $30, $30, $34, $18, $00 - .byte $00, $00, $CC, $CC, $CC, $CC, $76, $00 - .byte $00, $00, $CC, $CC, $CC, $78, $30, $00 - .byte $00, $00, $C6, $D6, $FE, $FE, $6C, $00 - .byte $00, $00, $C6, $6C, $38, $6C, $C6, $00 - .byte $00, $00, $CC, $CC, $CC, $7C, $0C, $F8 - .byte $00, $00, $FC, $98, $30, $64, $FC, $00 - .byte $1C, $30, $30, $E0, $30, $30, $1C, $00 - .byte $18, $18, $18, $00, $18, $18, $18, $00 - .byte $E0, $30, $30, $1C, $30, $30, $E0, $00 - .byte $76, $DC, $00, $00, $00, $00, $00, $00 - .byte $00, $10, $38, $6C, $C6, $C6, $FE, $00 + + .byte $3C, $66, $66, $66, $3C, $18, $7E, $18 + .byte $3F, $33, $3F, $30, $30, $70, $F0, $E0 + .byte $7F, $63, $7F, $63, $63, $67, $E6, $C0 + .byte $99, $5A, $3C, $E7, $E7, $3C, $5A, $99 + .byte $80, $E0, $F8, $FE, $F8, $E0, $80, $00 + .byte $02, $0E, $3E, $FE, $3E, $0E, $02, $00 + .byte $18, $3C, $7E, $18, $18, $7E, $3C, $18 + .byte $66, $66, $66, $66, $66, $00, $66, $00 + .byte $7F, $DB, $DB, $7B, $1B, $1B, $1B, $00 + .byte $3E, $63, $38, $6C, $6C, $38, $CC, $78 + .byte $00, $00, $00, $00, $7E, $7E, $7E, $00 + .byte $18, $3C, $7E, $18, $7E, $3C, $18, $FF + .byte $18, $3C, $7E, $18, $18, $18, $18, $00 + .byte $18, $18, $18, $18, $7E, $3C, $18, $00 + .byte $00, $18, $0C, $FE, $0C, $18, $00, $00 + .byte $00, $30, $60, $FE, $60, $30, $00, $00 + .byte $00, $00, $C0, $C0, $C0, $FE, $00, $00 + .byte $00, $24, $66, $FF, $66, $24, $00, $00 + .byte $00, $18, $3C, $7E, $FF, $FF, $00, $00 + .byte $00, $FF, $FF, $7E, $3C, $18, $00, $00 + .byte $00, $00, $00, $00, $00, $00, $00, $00 + .byte $30, $78, $78, $78, $30, $00, $30, $00 + .byte $6C, $6C, $6C, $00, $00, $00, $00, $00 + .byte $6C, $6C, $FE, $6C, $FE, $6C, $6C, $00 + .byte $30, $7C, $C0, $78, $0C, $F8, $30, $00 + .byte $00, $C6, $CC, $18, $30, $66, $C6, $00 + .byte $38, $6C, $38, $76, $DC, $CC, $76, $00 + .byte $60, $60, $C0, $00, $00, $00, $00, $00 + .byte $18, $30, $60, $60, $60, $30, $18, $00 + .byte $60, $30, $18, $18, $18, $30, $60, $00 + .byte $00, $66, $3C, $FF, $3C, $66, $00, $00 + .byte $00, $30, $30, $FC, $30, $30, $00, $00 + .byte $00, $00, $00, $00, $00, $30, $30, $60 + .byte $00, $00, $00, $FC, $00, $00, $00, $00 + .byte $00, $00, $00, $00, $00, $30, $30, $00 + .byte $06, $0C, $18, $30, $60, $C0, $80, $00 + .byte $7C, $C6, $CE, $DE, $F6, $E6, $7C, $00 + .byte $30, $70, $30, $30, $30, $30, $FC, $00 + .byte $78, $CC, $0C, $38, $60, $CC, $FC, $00 + .byte $78, $CC, $0C, $38, $0C, $CC, $78, $00 + .byte $1C, $3C, $6C, $CC, $FE, $0C, $1E, $00 + .byte $FC, $C0, $F8, $0C, $0C, $CC, $78, $00 + .byte $38, $60, $C0, $F8, $CC, $CC, $78, $00 + .byte $FC, $CC, $0C, $18, $30, $30, $30, $00 + .byte $78, $CC, $CC, $78, $CC, $CC, $78, $00 + .byte $78, $CC, $CC, $7C, $0C, $18, $70, $00 + .byte $00, $30, $30, $00, $00, $30, $30, $00 + .byte $00, $30, $30, $00, $00, $30, $30, $60 + .byte $18, $30, $60, $C0, $60, $30, $18, $00 + .byte $00, $00, $FC, $00, $00, $FC, $00, $00 + .byte $60, $30, $18, $0C, $18, $30, $60, $00 + .byte $78, $CC, $0C, $18, $30, $00, $30, $00 + .byte $7C, $C6, $DE, $DE, $DE, $C0, $78, $00 + .byte $30, $78, $CC, $CC, $FC, $CC, $CC, $00 + .byte $FC, $66, $66, $7C, $66, $66, $FC, $00 + .byte $3C, $66, $C0, $C0, $C0, $66, $3C, $00 + .byte $F8, $6C, $66, $66, $66, $6C, $F8, $00 + .byte $7E, $60, $60, $78, $60, $60, $7E, $00 + .byte $7E, $60, $60, $78, $60, $60, $60, $00 + .byte $3C, $66, $C0, $C0, $CE, $66, $3E, $00 + .byte $CC, $CC, $CC, $FC, $CC, $CC, $CC, $00 + .byte $78, $30, $30, $30, $30, $30, $78, $00 + .byte $1E, $0C, $0C, $0C, $CC, $CC, $78, $00 + .byte $E6, $66, $6C, $78, $6C, $66, $E6, $00 + .byte $60, $60, $60, $60, $60, $60, $7E, $00 + .byte $C6, $EE, $FE, $FE, $D6, $C6, $C6, $00 + .byte $C6, $E6, $F6, $DE, $CE, $C6, $C6, $00 + .byte $38, $6C, $C6, $C6, $C6, $6C, $38, $00 + .byte $FC, $66, $66, $7C, $60, $60, $F0, $00 + .byte $78, $CC, $CC, $CC, $DC, $78, $1C, $00 + .byte $FC, $66, $66, $7C, $6C, $66, $E6, $00 + .byte $78, $CC, $E0, $70, $1C, $CC, $78, $00 + .byte $FC, $30, $30, $30, $30, $30, $30, $00 + .byte $CC, $CC, $CC, $CC, $CC, $CC, $FC, $00 + .byte $CC, $CC, $CC, $CC, $CC, $78, $30, $00 + .byte $C6, $C6, $C6, $D6, $FE, $EE, $C6, $00 + .byte $C6, $C6, $6C, $38, $38, $6C, $C6, $00 + .byte $CC, $CC, $CC, $78, $30, $30, $78, $00 + .byte $FE, $06, $0C, $18, $30, $60, $FE, $00 + .byte $78, $60, $60, $60, $60, $60, $78, $00 + .byte $C0, $60, $30, $18, $0C, $06, $02, $00 + .byte $78, $18, $18, $18, $18, $18, $78, $00 + .byte $10, $38, $6C, $C6, $00, $00, $00, $00 + .byte $00, $00, $00, $00, $00, $00, $00, $FF + .byte $30, $30, $18, $00, $00, $00, $00, $00 + .byte $00, $00, $78, $0C, $7C, $CC, $76, $00 + .byte $E0, $60, $60, $7C, $66, $66, $DC, $00 + .byte $00, $00, $78, $CC, $C0, $CC, $78, $00 + .byte $1C, $0C, $0C, $7C, $CC, $CC, $76, $00 + .byte $00, $00, $78, $CC, $FC, $C0, $78, $00 + .byte $38, $6C, $60, $F0, $60, $60, $F0, $00 + .byte $00, $00, $76, $CC, $CC, $7C, $0C, $F8 + .byte $E0, $60, $6C, $76, $66, $66, $E6, $00 + .byte $30, $00, $70, $30, $30, $30, $78, $00 + .byte $0C, $00, $0C, $0C, $0C, $CC, $CC, $78 + .byte $E0, $60, $66, $6C, $78, $6C, $E6, $00 + .byte $70, $30, $30, $30, $30, $30, $78, $00 + .byte $00, $00, $CC, $FE, $FE, $D6, $C6, $00 + .byte $00, $00, $F8, $CC, $CC, $CC, $CC, $00 + .byte $00, $00, $78, $CC, $CC, $CC, $78, $00 + .byte $00, $00, $DC, $66, $66, $7C, $60, $F0 + .byte $00, $00, $76, $CC, $CC, $7C, $0C, $1E + .byte $00, $00, $DC, $76, $66, $60, $F0, $00 + .byte $00, $00, $7C, $C0, $78, $0C, $F8, $00 + .byte $10, $30, $7C, $30, $30, $34, $18, $00 + .byte $00, $00, $CC, $CC, $CC, $CC, $76, $00 + .byte $00, $00, $CC, $CC, $CC, $78, $30, $00 + .byte $00, $00, $C6, $D6, $FE, $FE, $6C, $00 + .byte $00, $00, $C6, $6C, $38, $6C, $C6, $00 + .byte $00, $00, $CC, $CC, $CC, $7C, $0C, $F8 + .byte $00, $00, $FC, $98, $30, $64, $FC, $00 + .byte $1C, $30, $30, $E0, $30, $30, $1C, $00 + .byte $18, $18, $18, $00, $18, $18, $18, $00 + .byte $E0, $30, $30, $1C, $30, $30, $E0, $00 + .byte $76, $DC, $00, $00, $00, $00, $00, $00 + .byte $00, $10, $38, $6C, $C6, $C6, $FE, $00 diff --git a/libsrc/pce/waitvblank.s b/libsrc/pce/waitvblank.s index 2ded2835e..b4e31f45a 100644 --- a/libsrc/pce/waitvblank.s +++ b/libsrc/pce/waitvblank.s @@ -2,17 +2,15 @@ ; void waitvblank (void); ; - .include "pce.inc" + .include "pce.inc" .export _waitvblank -;; .importzp tickcount .proc _waitvblank - lda tickcount -@lp: cmp tickcount - beq @lp + lda tickcount +@lp: cmp tickcount + beq @lp rts .endproc - diff --git a/testcode/lib/pce/conio.c b/testcode/lib/pce/conio.c index f5231dba6..44da30a2a 100644 --- a/testcode/lib/pce/conio.c +++ b/testcode/lib/pce/conio.c @@ -9,113 +9,113 @@ static int datavar = 10; void main(void) { - int stackvar = 42; - int i, j; - clock_t clk; - char *p; - unsigned char xsize, ysize, n; - - joy_install(&joy_static_stddrv); - - clrscr(); - screensize(&xsize, &ysize); - - 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 (i = 0; i < 4; ++i) { - gotoxy(0, 17 + i); - p = malloc(16); - memcpy(p, "01234567890abcdef", 16); - cprintf("alloced at: %04p - %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", p, - p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15] - ); - } - - gotoxy(0,ysize - 1); - for (i = 0; i < xsize; ++i) { - cputc('0' + i % 10); - } - - gotoxy(0,ysize - 2 - ((256 + xsize) / xsize)); - for (i = 0; i < xsize; ++i) { - cputc('0' + i % 10); - } - for (i = 0; i < (xsize * 5); ++i) { - cputc('#'); - } - gotoxy(0,ysize - 1 - ((256 + xsize) / xsize)); - for (i = 0; i < 256; ++i) { - if ((i != '\n') && (i != '\r')) { - cputc(i); + int stackvar = 42; + int i, j; + clock_t clk; + char* p; + unsigned char xsize, ysize, n; + + joy_install(&joy_static_stddrv); + + clrscr(); + screensize(&xsize, &ysize); + + cputs("hello world"); + cputsxy(0, 2, "colors:" ); + for (i = 0; i < 16; ++i) { + textcolor(i); + cputc('X'); } - } - - i = get_tv(); - gotoxy(30,0); - cputs("TV Mode: "); - switch(i) { - case TV_NTSC: - cputs("NTSC"); - break; - case TV_PAL: - cputs("PAL"); - break; - case TV_OTHER: - cputs("OTHER"); - break; - } - cprintf(" %dx%d", xsize, ysize); - - for(;;) { - gotoxy(13,4); - cprintf("%02x", datavar); - gotoxy(13,5); - cprintf("%02x", stackvar); - ++datavar; ++stackvar; - - gotoxy(0,8); - clk = clock(); - cprintf("clock: %08lx", clk); - - for (i = 0; i < 4; ++i) - { - gotoxy(0, 12 + i); - j = joy_read (i); - cprintf ("pad %d: %02x %-6s%-6s%-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 " : " ---- ", - (j & joy_masks[JOY_SELECT])? "select" : " ---- ", - (j & joy_masks[JOY_RUN])? " run " : " ---- "); + 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 (i = 0; i < 4; ++i) { + gotoxy(0, 17 + i); + p = malloc(16); + memcpy(p, "01234567890abcdef", 16); + cprintf("alloced at: %04p - %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", p, + p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7], + p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15] + ); } - gotoxy(xsize - 10, 3); - j = (n >> 5) & 1; - revers(j); - cputc(j ? 'R' : ' '); - cputs(" revers"); - revers(0); - - waitvblank(); - ++n; - } - for(;;); + gotoxy(0,ysize - 1); + for (i = 0; i < xsize; ++i) { + cputc('0' + i % 10); + } + + gotoxy(0,ysize - 2 - ((256 + xsize) / xsize)); + for (i = 0; i < xsize; ++i) { + cputc('0' + i % 10); + } + for (i = 0; i < (xsize * 5); ++i) { + cputc('#'); + } + gotoxy(0,ysize - 1 - ((256 + xsize) / xsize)); + for (i = 0; i < 256; ++i) { + if ((i != '\n') && (i != '\r')) { + cputc(i); + } + } + + i = get_tv(); + gotoxy(30,0); + cputs("TV Mode: "); + switch(i) { + case TV_NTSC: + cputs("NTSC"); + break; + case TV_PAL: + cputs("PAL"); + break; + case TV_OTHER: + cputs("OTHER"); + break; + } + cprintf(" %dx%d", xsize, ysize); + + for(;;) { + gotoxy(13,4); + cprintf("%02x", datavar); + gotoxy(13,5); + cprintf("%02x", stackvar); + ++datavar; ++stackvar; + + gotoxy(0,8); + clk = clock(); + cprintf("clock: %08lx", clk); + + for (i = 0; i < 4; ++i) { + gotoxy(0, 12 + i); + j = joy_read (i); + cprintf ("pad %d: %02x %-6s%-6s%-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 " : " ---- ", + (j & joy_masks[JOY_SELECT])? "select" : " ---- ", + (j & joy_masks[JOY_RUN])? " run " : " ---- "); + } + + gotoxy(xsize - 10, 3); + j = (n >> 5) & 1; + revers(j); + cputc(j ? 'R' : ' '); + cputs(" revers"); + revers(0); + + waitvblank(); + ++n; + } + for(;;); } -- 2.39.5