Author Topic: CHIPCE-8: CHIP-8 interpreter for the PCE  (Read 813 times)

trapexit

  • Newbie
  • *
  • Posts: 19
Re: CHIPCE-8: CHIP-8 interpreter for the PCE
« Reply #15 on: December 12, 2014, 07:15:35 AM »
I'm interested. Yeah... CHIP-8 wasn't double buffered but it'd be interesting to try.

I'm currently using vsync handler to deal with the CHIP-8 timers[0].

Code: [Select]
void chip8_vsync_hook(void) __mapcall __irq
{
}

irq_add_vsync_handler(chip8_vsync_hook);
irq_enable_user(IRQ_VSYNC);

I'm now noticing there is IRQ_HSYNC but no irq_add_hsync_handler.

[ul][li] https://github.com/trapexit/chipce8/blob/master/HuC/emulator.c#L77[/li][/ul]

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: CHIPCE-8: CHIP-8 interpreter for the PCE
« Reply #16 on: December 12, 2014, 08:30:03 AM »
Here: http://pcedev.net/HuC/Chsync_ver_1_1/chsync_ver1_1.zip

HuC mimics the SCD environment for IRQ management, so it follows the same rules. So I manually did this:

Code: [Select]
/*.......................................................................................*/
EnableCustomHsync()
{
#asm                         
  php
  sei
  lda irq_m
  sta _irq_m_backup
  ora #$d0                    ;;// disable int hsync handler, enable custom handler. Attach custom vsync handler
  sta irq_m
  lda #low(cust_hsync.1)
  sta hsync_hook
  lda #high(cust_hsync.1)
  sta hsync_hook+1
  lda #low(cust_vsync.1)
  sta vsync_hook
  lda #high(cust_vsync.1)
  sta vsync_hook+1
  lda <vdc_crl
  ora #$04
  sta <vdc_crl
  st0 #$06
  st1 #$00
  st2 #$00
  plp
 
 
 
#endasm
}

 The actual handler is in the library.asm file. Just modify that as needed, or replace it completely. If you need HuC's vsync functionality, you could always call yours first and then jump to the original (it'll RTI from inside there). Pretty sure you'll need to do this for HuC lib gamepad routines to work (IIRC), unless you call that manually as well or such.