Author Topic: Yokai Dochuki - 妖怪道中記  (Read 906 times)

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Yokai Dochuki - 妖怪道中記
« Reply #30 on: June 16, 2011, 05:46:21 PM »
Youkai Douchuuki has a near-fatal(it's a wonder it works at all) bug in its startup code; it JSRs before setting the MPR for 0x2000-0x3FFF to 0xF8, sets the MPR to 0xF8, and then RTS's to who-knows-where on the real system, presumably executing a BRK sooner or later which calls the startup code again(the vectors used for reset and BRK contain the same addresses in the game) with the 0x2000-0x3FFF MPR valid this time.


Tell you what. I bet some of us could make sense of this if use replaced the abbreviations/acronyms with full terms. I can't even find on-line what a JSR is, for example.


Jump to Subroutine.

http://en.wikipedia.org/wiki/Jump_to_subroutine#Jump_to_subroutine

first hit on google... >_> lol


[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

blueraven

  • Hero Member
  • *****
  • Posts: 4450
Re: Yokai Dochuki - 妖怪道中記
« Reply #31 on: June 16, 2011, 06:02:01 PM »
Youkai Douchuuki has a near-fatal(it's a wonder it works at all) bug in its startup code; it JSRs before setting the MPR for 0x2000-0x3FFF to 0xF8, sets the MPR to 0xF8, and then RTS's to who-knows-where on the real system, presumably executing a BRK sooner or later which calls the startup code again(the vectors used for reset and BRK contain the same addresses in the game) with the 0x2000-0x3FFF MPR valid this time.

Holy Shit.
[Thu 10:04] <Tatsujin> hasd a pasrtty asnd a after pasrty ASDFTERTHE PARTY
[Fri 22:47] <Tatsujin> CLOSE FIGHTING STREET; CLOSE FORU; CLOSE INTERNETZ; CLOSE WORLD; CLOSE UNIVERSUM
--
Arkhan [05:15pm]: ill brbl im going to go make another free game noone plays lolol

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Yokai Dochuki - 妖怪道中記
« Reply #32 on: June 17, 2011, 03:59:53 AM »
Youkai Douchuuki has a near-fatal(it's a wonder it works at all) bug in its startup code; it JSRs before setting the MPR for 0x2000-0x3FFF to 0xF8, sets the MPR to 0xF8, and then RTS's to who-knows-where on the real system, presumably executing a BRK sooner or later which calls the startup code again(the vectors used for reset and BRK contain the same addresses in the game) with the 0x2000-0x3FFF MPR valid this time.

Tell you what. I bet some of us could make sense of this if use replaced the abbreviations/acronyms with full terms. I can't even find on-line what a JSR is, for example.

 JSR and RTS are pretty common terms in assembly language, regardless of the CPU. JSR calls a subroutine (for which you can return back). RTS is the return instruction for the JSR, ReTurn from Subroutine. Uses the stack. The address following the JSR (the PC is pushed onto the stack) is pushed to the stack, but the stack is in ram and in a fixed location. RAM hasn't been mapped yet, so when the RTS hits whatever the stack pointer is at and whatever is mapped is popped from that address (stack+stack pointer). The BRK is BREAK opcode on the PCE. It's basically a software interrupt call. Since it's mapped to the same location as the Reset Vector (the address for the PC (Program Counter) on reset/power up), eventually the cpu should execute either random data, ports, or open bus as BRK (opcode $00) and thus fix itself. I've seen famicom games map BRK to Reset as well. Matter of fact, Megaman resets the whole game for every level selection (and after every level completion or no continue on out of lives), and level select screen.

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Yokai Dochuki - 妖怪道中記
« Reply #33 on: June 17, 2011, 12:36:35 PM »
Thanks, Bonknuts. I am familiar with programming ideas and terminology, but not so much with assembly or assembly abbreviations. Once I know the abbreviations I can get an idea of what's going on. Arkhan, I searched for JSR but I kept getting stuff related to Java Specification Requests. And that block of babble will make perfect sense to me once I get the last piece, what an MPR is.  : )
<a href="http://www.pcedaisakusen.net/2/34/103/show-collection.htm" class="bbc_link" target="_blank">My meager PC Engine Collection so far.</a><br><a href="https://www.pcenginefx.com/forums/" class="bbc_link" target="_blank">PC Engine Software Bible</a><br><a href="http://www.racketboy.com/forum/" c

TheOldMan

  • Hero Member
  • *****
  • Posts: 958
Re: Yokai Dochuki - 妖怪道中記
« Reply #34 on: June 17, 2011, 01:40:47 PM »
Quote
what an MPR is.  : )
Not sure what the abreviation means, but that's the part of the cpu chip that maps physical memory (up to 1M byte) to cpu logical memory (64K bytes). Changing the values map different parts of physical memory into where the cpu can actually use it.
And for reference, I believe block f8 is the system RAM. So effectively, the code tries to stack the return address from the subroutine call somewhere that doesn't exist (to the cpu). Then, when it tries to return from the subroutine, it's anyones guess where it actually returns to.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Yokai Dochuki - 妖怪道中記
« Reply #35 on: June 17, 2011, 03:25:08 PM »
Quote
the cpu chip that maps physical memory (up to 1M byte)

Actually, the physical address range is 2megabytes. The hucard games have only uses the lower 1megabyte, but the hucard port itself is the full 2megabyte range. It's how the Arcade card maps into its registers into bank $FF at location $1a00-1aff. There's lots of other free/open bus space in the upper 2megabyte range as well. I think it's just that NEC reserved it for back end peripherals for developers, but that's only by choice - not function. With a tiny bit of glue logic and no mapper required, you could technically make a 12megabit hucard (and bigger too). IIRC, banks $88 to $F6 are open bus. And bank $F8 has open bus from $1c00 to $1ffff still open, after the arcade takes what it needs (great for mapping in new hardware device registers).

Quote
what an MPR is

 I forget what it stands for. But the R stands for Register. Though we tend to say MPR register, which is redundant. Probably MaPper Register. The cpu has a logical address range and a physical address range. Unlike the original line of 65x CPUs that only have 16bit physical (64k) and logical (64k) address ranges, the PCE's 6280 has 16bit logical and 21bit external address ranges(2048k or 2megabytes or 16megabits). This means there's not need for additional hardware like external mappers to get past the physical address limitations (like NES or A8 or C64, etc). Anyway, the logical address range is 16bit or 64k. This 64k is divided neatly into 8 segments of 8k. So $0000-$1fff, $2000-$3fff, etc. The stack pointer register is an indexing register, but the base address for the STACK itself is fixed at location $2100 of logical address range. So no matter what you have mapped there, it will try to read or write from $2100 to $21ff range (8bit index). Some other things are fixed in location too. Zeropage (these are basically Address registers for any other type of processor and general purpose as well, with one distinction that they exist external to the CPU. Makes is cheaper for the CPU, though at a cost of an additional cycle or two - but the amount of registers (especially Addressing) is increased dramatically) is fixed at $2000-$20ff logical range. All the interrupt vectors reside in $fff6-$ffff logical address range. So, ram needs to exist at least at $2000-21fff range for ZP and STACK to work correctly (disregarding all-rom-mode and writing special code for that setup, waaaaaaaay beyond the scope of this topic). So you have MPR 0 to MPR 7. MPR 0 being $0000-$1fff and MPR 7 being $e000 to $ffff. On power up, the only MPR mapped with a specific constant value is MPR 7. And it automatically mapped to physical address range $000000-$001fff. A game can put whatever addresses it wants for any of the 5 interrupt vectors, but Reset (start up code) should always have a logical address range of $e000-$fffff, since nothing else is guaranteed to be mapped. If you don't use BRK for anything, you could always use it as a generic bug trapping feature. And if you put the same address value as the Reset vector, then you'll just get a restart (although game code could easily be made to look at ram and see if it's been previously initialized with an ID string, and thus call an output message. Or do nothing at all and just let the game reset. No fun to the gamer either way).

 I digress a bit, but it would have been nice to have just a few special long address opcodes. Easy enough, since mapping is all handled internally. Even opcodes specifically for transferring values from the Acc register between the MPR registers (they're cpu based). MPR<n>+PC address mode, 24bit direct addressing (similar to paging on the x86). But oh well, it's not needed for speed - just convenience. And I always find something to rant about that's "should have been added".

IDCHAPPY

  • Newbie
  • *
  • Posts: 21
Re: Yokai Dochuki - 妖怪道中記
« Reply #36 on: June 30, 2011, 09:04:04 AM »
This might explain about the dud copy i thought i got  :-k