Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemioUrbina committed Nov 15, 2023
1 parent 352dc61 commit ede08c9
Show file tree
Hide file tree
Showing 143 changed files with 15,321 additions and 2,842 deletions.
56 changes: 0 additions & 56 deletions .gitignore

This file was deleted.

2 changes: 2 additions & 0 deletions BSDmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
JOBS = -j$(.MAKE.JOBS)
.endif

.PHONY: all clean examples test check package

all clean examples test check package:
gmake $(JOBS) $@
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ install:
cp -pr include/huc/* /usr/include/huc/

test:
cd test ; ./mk
@cd test ; /bin/sh ./test_compiler.sh

check:
@echo ''
dos2unix examples/huc/checksum.txt
md5sum -c < examples/huc/checksum.txt
@cd test ; /bin/sh ./test_examples.sh


DATE = $(shell date +%F)
ifneq ($(OS),Windows_NT)
Expand Down
7 changes: 6 additions & 1 deletion examples/asm/elmer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
#

PREREQS = ipl-scd
SUBDIRS = scd-bios-hello scd-bios-hello-error rom-core-hello cd-core-1stage cd-core-2stage scd-core-1stage scd-core-2stage scd-core-1stage-error scd-core-2stage-error rom-kickc-hello rom-kickc-shmup
SUBDIRS = rom-bare-tiatest rom-bare-vdctest scd-bios-hello scd-bios-hello-error \
rom-core-hello rom-core-okitest \
cd-core-1stage cd-core-2stage scd-core-1stage scd-core-1stage-error \
scd-core-2stage scd-core-2stage-error scd-core-fastcd \
rom-kickc-hello rom-kickc-shmup ted2-core-hwdetect ted2-core-sdcard \
ted2-core-gulliver

all clean:
@$(MAKE) $(PREREQS) "COMMAND=$@"
Expand Down
21 changes: 21 additions & 0 deletions examples/asm/elmer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ This directory contains a number of example programs and utilities for developin
* ted2-bios-usbcd
- A modified System Card 3.0 HuCARD that runs a CD-ROM overlay uploaded through USB, rather than loading it from CD-ROM.

* rom-bare-tiatest
- A HuCARD ROM to compare a PC Engine emulator's TIA-to-VDC cycle timing with real PC Engine console hardware.

* rom-bare-vdctest
- A HuCARD ROM to compare a PC Engine emulator's VDC RCR interrupt handling with real PC Engine console hardware.

* rom-core-okitest
- A HuCARD ROM to compare a PC Engine emulator's ADPCM playback flags and ADPCM write speed with real PC Engine console hardware.


## Using the System Card BIOS

Expand Down Expand Up @@ -50,6 +59,18 @@ The "CORE(not TM)" PC Engine library is a small and configurable set of library
* scd-core-2stage-error
- An expansion of scd-core-2stage, using an error overlay to show a pretty screen when run with System Card 2.0 or earlier.

* scd-core-fastcd
- An example of CD-ROM initialization, reading files and streaming ADPCM using the "fast" CD routines.

* ted2-core-hwdetect
- An example of detecting PC Engine hardware and testing the Joypads and Mice attached to the console.

* ted2-core-sdcard
- An example of reading and writing a file from the SDcard on a Turbo EverDrive v2.

* ted2-core-gulliver
- An example of playing a HuVIDEO movie from Hudson's GulliverBoy CD-ROM game.


## Getting started with the KickC compiler

Expand Down
13 changes: 6 additions & 7 deletions examples/asm/elmer/cd-core-1stage/stage1.asm
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ core_main: ; Turn the display off and initialize the screen mode.

; Upload the font to VRAM.

lda #<my_font ; Address of font data.
sta <_si + 0
lda #>my_font
sta <_si + 1
lda #^my_font
sta <_si_bank

stz <_di + 0 ; Destination VRAM address.
lda #>(CHR_0x10 * 16)
sta <_di + 1
Expand All @@ -127,6 +120,12 @@ core_main: ; Turn the display off and initialize the screen mode.
lda #16 + 96 ; 16 graphics + 96 ASCII.
sta <_bl

lda #<my_font ; Address of font data.
sta <_bp + 0
lda #>my_font
sta <_bp + 1
ldy #^my_font

call dropfnt8x8_vdc ; Upload font to VRAM.

; Upload the palette data to the VCE.
Expand Down
39 changes: 18 additions & 21 deletions examples/asm/elmer/cd-core-2stage/stage2.asm
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,21 @@ core_main: ; Turn the display off and initialize the screen mode.

; Decompress the font data.

lda.l #my_font ; Address of font data.
sta.l <_si
lda.h #my_font
sta.h <_si
lda #^my_font
sta <_si_bank

lda.l #FONT_BUFFER ; Destination buffer.
sta.l <_di
lda.h #FONT_BUFFER
sta.h <_di

lda.l #my_font ; Address of font data.
sta.l <_bp
lda.h #my_font
sta.h <_bp
ldy #^my_font

call zx0_to_ram ; Decompress the font.

; Upload the font to VRAM.

lda.l #FONT_BUFFER ; Address of font data.
sta.l <_si
lda.h #FONT_BUFFER
sta.h <_si
lda #$F8 ; RAM bank.
sta <_si_bank

stz.l <_di ; Destination VRAM address.
lda #>(CHR_0x20 * 16)
sta.h <_di
Expand All @@ -145,19 +137,24 @@ core_main: ; Turn the display off and initialize the screen mode.
lda #96 ; 96 ASCII.
sta <_bl

lda.l #FONT_BUFFER ; Address of font data.
sta.l <_bp
lda.h #FONT_BUFFER
sta.h <_bp
cly ; Do not change MPR3.

call dropfnt8x8_vdc ; Upload font to VRAM.

; Upload the palette data to the VCE.

lda.l #cpc464_colors ; Set the ptr to the palette
sta.l <_si ; data.
lda.h #cpc464_colors
sta.h <_si
lda #^cpc464_colors
sta <_si_bank
stz <_al ; Start at palette 0 (BG).
lda #1 ; Copy 1 palette of 16 colors.
sta <_ah
lda #<cpc464_colors ; Set the ptr to the palette
sta.l <_bp ; data.
lda #>cpc464_colors
sta.h <_bp
ldy #^cpc464_colors
call load_palettes ; Add to the palette queue.

call xfer_palettes ; Transfer queue to VCE now.
Expand Down Expand Up @@ -225,7 +222,7 @@ core_main: ; Turn the display off and initialize the screen mode.
; $6 = yellow font
;

WORD_ALIGN
align 2
cpc464_colors: dw $0000,$0001,$01B2,$01B2,$0002,$004C,$0169,$01B2
dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000

Expand Down
Binary file added examples/asm/elmer/data/alice.ram
Binary file not shown.
Binary file added examples/asm/elmer/data/alice.vdc
Binary file not shown.
Binary file added examples/asm/elmer/data/pointer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/asm/elmer/data/pointer.spr
Binary file not shown.
Binary file added examples/asm/elmer/data/red_queen-16k.vox
Binary file not shown.
Binary file added examples/asm/elmer/data/testspr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/asm/elmer/data/texture.chr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�޼�ڽc� ��gg��o�����������������c�ק�ٷ:�F�w�����������������
Binary file added examples/asm/elmer/data/texture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/asm/elmer/data/umbrella-16k.vox
Binary file not shown.
72 changes: 72 additions & 0 deletions examples/asm/elmer/doc/adpcm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
; ***************************************************************************
; PC ENGINE ADPCM HARDWARE NOTES
; ***************************************************************************

/* Mednafen - Multi-system Emulator
*
* Copyright notice for this file:
* Copyright (C) 2004 Ki
* Copyright (C) 2007-2011 Mednafen Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/


Reading from IFU_ADPCM_DAT decrements LENGTH. Appears to saturate at 0x0000.

Side effects include at least setting IFU_INT_HALF.

When the IFU_INT_END flags are set by a read from IFU_ADPCM_DAT, then the
IFU_INT_HALF flag appears to be cleared.
This is different from normal ADPCM playback, where both IFU_INT_END and
IFU_INT_HALF flags are set by the end of playback.

Note that if ADPCM_AUTO of IFU_ADPCM_CTL is cleared, then the IFU_INT_HALF
flag seems to be cleared on the next sample clock, either intentionally or
due to some kind of length underflow, I don't know; but the behavior when
ADPCM_AUTO cleared is buggy, and I doubt games rely on any of its weirder
nuances.

Writing to IFU_ADPCM_DAT increments LENGTH. Appears to saturate at 0xFFFF.

Side effects include at least setting/clearing IFU_INT_HALF.

For IFU_ADPCM_DAT port read/write accesses at least, the IFU_INT_HALF flag
is set by (LENGTH < $8000), evaluated before LENGTH is either decremented
or incremented.

ADPCM RAM reads due to playback apparently aren't reflected in IFU_ADPCM_FLG
as the ADPCM_RD_BSY state.
Unknown if it shares the same buffer as IFU_ADPCM_DAT port reads though.

Setting ADPCM_SET_SZ in IFU_ADPCM_CTL clears both the ADPCM_AD_END and the
IFU_INT_END flags, and they will not be set as long as ADPCM_SET_SZ is set.
It doesn't clear the IFU_INT_HALF flag though.
Short of resetting the ADPCM hardware, this was the only way I could find to
clear the ADPCM_AD_END and IFU_INT_END flags via software.

Setting ADPCM_SET_SZ in IFU_ADPCM_CTL does NOT stop the IFU_INT_HALF flag
from being set (at least not during reads/writes to IFU_ADPCM_DAT).

ADPCM playback doesn't seem to start when the ADPCM_AD_END and IFU_INT_END
flags are set and 0x60 (ADPCM_PLAY+ADPCM_AUTO) is written to IFU_ADPCM_CTL,
but starts if only ADPCM_PLAY is written (i.e. ADPCM_AUTO is clear).
More investigation is needed (unlikely to affect games though).

ADPCM playback starting is likely delayed (or at certain intervals) compared
to writes to IFU_ADPCM_CTL.
Investigation is needed, but emulating a non-constant granularity-related
delay may be undesirable due to the potential of triggering race conditions
in game code.
Loading

0 comments on commit ede08c9

Please sign in to comment.