Darendor vs Assembly Language

Anything you like and probably not related to Bard's Tale
Post Reply
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Darendor vs Assembly Language

Post by Darendor »

I occasionally - very occasionally - become motivated to attempt a project that I have little to no experience in doing. Why? I don't know, exactly. Boredom, I suppose. Waiting on employment. Having too much time throughout the day.

I have always been somewhat passionate about Bard's Tale on the Commodore 64; more accurately, I feel that a construction kit should have been developed based on the BTII game engine. I remember reading years ago now about an interview that Michael Cranford did where he was asked how he went about building the game in his home, and he said he had written programs where he could do things like add darkness to a given square by pressing a key and so forth. So I thought to myself, "why couldn't someone else do that?".

I'm aware that Bard's Tale II is technically copyrighted software, and I'm probably breaking some civil tort law with my endeavor to build a BTCS, as it were, but I figure since 1986 was a veritable lifetime ago that nobody of consequence will mind...

Having said that, I picture Mr Cranford furrowing his brow at me should he get wind of what I'm attempting.

But in the first place, it would seem that the secrets of BTII are somewhat safe from being discovered by me, because my assembly language skills are, well, bad. I mean, I knew I was a novice and I've taken to having the Programmer's Reference Guide PDF open, and 4 or 5 copies of Notepad with various notes, one of which has a list of things to try to implement, and a few forums. I also have Calculator.exe open in "Programmer Mode", which is useful because I can't add in hexadecimal for beans.

So anyhow, about 2 months ago I thought to myself, "I have the file for the Wilderness/City monster roster decoded, let's see if I can't make an editor for it". The proof-of-concept being that anyone could edit the roster monsters to whatever they wanted.

I had it up to the point where all of the damn calculations were complete. Some were trial and error, some I had to consult with others on, and a few I just figured out on the first go. I thought I was pretty clever because I had written "self-modifying code" that saved tons of space for paging through the monster entries.

And so, one morning I was pressing F3 checking to see if the stats and whatnot were displaying correctly, and they were, until I came upon the "Forest Giant" entry. And then I discovered that the game uses a shifted-space to separate words. So instead of "Forest Giant", it was displaying "Forest[CBM graphics character]Giant", and to add insult to injury there were corrupted characters on the screen that had no business being there.

My heart sank. I had a rather bad habit of not allowing space when coding subroutines (going back to my BASIC days), so any solution had to be equal to or less than the length of the offending code. That, or I had to substitute a JMP $???? where the bad code was and find a spot somewhat to put in the corrected code.

So the obvious (to me) solution was to put in a pair of instructions; one was to CMP the shifted space character, and if it matched print a normal (#$20) space in its place. Easy, right? Yeah, I though so too...

...a week later, and about 2 dozen tries, and I'm still not able to fix the problem. Why? I have no damn idea. It should have worked. Only, it didn't.

I finally, today, managed to fix the code. I saved the emulator state, then went through, and found that, finally, it prints everything correctly. So I made a blank .D64 image, and saved the binary file as "BUILD4.PRG".

I reset the WinVICE program, and loaded the file into memory, and typed SYS 16384. The welcome screen greeted me and prompted me for the CHARACTER disk. Disk image swapped, hit RETURN, file loads....

...and immediately after "Root Name: " the screen endlessly fills with "j" and "T" characters.

I break into the monitor, and I check the memory location where the file was supposed to be loaded ($33EA), and the location where it was supposed to be EOR'd against #$EA ($3628). Instead of the file contents, I'm greeted with "FF" and "00".

The damn file failed to load, even though the program behaved as though it did.

Siiiiiiiiiiigh.....

Stymied (for the 123rd time in a few weeks), I went to the Lemon64.com forums and posted what was going on, and the code that I had that loaded the file into memory.

It was pointed out to me that I had the .A, .X, and .Y values all wrong for the KERNAL's "LOAD" ($FFD5) routine.

Now, that's fine, I see where I went wrong. Only, once upon a time, it worked since the data was in memory when I saved the emulator state, so....WTF?

I should give up, but my determination and drive won't let me. I will say I'm becoming tired of having things go sideways on me all the time. It's like every time I type SYS 16384 and hit RETURN, I'm just begging for it to screw up. CPU jam? Yep. Screen lock up? Uh huh. Random bizarre characters flooding the screen endlessly? Check.

I ponder whether I should even be bothering. I'm clearly dealing with arcane sorcery here.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: Darendor vs Assembly Language

Post by Darendor »

So I have taken a LUNESTA pill to help me sleep.

While I'm waiting for itt o kikc in I deacided to try to try to write the cat is meowing code.........................

Will this work??

Code: Select all

lda $4293
cmp #$28
beq $alpha
cmp #$08
beq #$beta

  charlie
lda $4293
sbc #$1f
jsr $59a0
jmp $4273

  alpha
lda $4294
cmp #$36
beq $delta
jsr $5a62	DEC subroutine
jmp $charlie

  beta
jsr $5a62
lda #$e8
jsr $59a0
jmp $4273

  delta
jmp $57a0

Only TIM will tell.......
Post Reply