6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 16, 2024 2:02 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Problems with Microchess
PostPosted: Sat Dec 17, 2005 2:04 pm 
Offline

Joined: Tue Dec 10, 2002 11:00 am
Posts: 16
Location: West Yorkshire, UK
Hi,
I'm trying to modify Microchess (Daryl Rictor's modified version) to run from ROM on my 6502 board. RAM is 32Kbytes from $0000 to $7FFF, ROM is from $C000 to FFFF (16k).

I've changed both of the assembly origin (*=) directives so MC is based at $C000, and replaced the ACIA routines with dummy routines that just JSR to the monitor ROM. This was enough to get MC (mostly) running, but it seems to be getting stuck in a loop while it draws the board. Here's where it's getting stuck:

Code:
      ADC   #$08      ; point y to beginning of next row
      TAY         ;
      CPY      #$80      ; was that the last row?
      BEQ      POUT8      ; yes, print the LED values
;   for some reason the beq pout8 never fires
      BNE      POUT1      ; no, do new row


Also, it seems the chess board isn't getting initialised. Do I need to do any initialisation before JMPing to $C000?
The monitor ROM doesn't touch X or Y, but all the UART comms routines clobber the accumulator and the flags. The code I've inserted into MC does a PHA, then the JSR, then a PLA and an RTS, so register clobbering shouldn't be an issue...

Has anyone got any suggestions? I was going to step through the code with my logic analyser, but I can't get a decent connection to the data bus (damn test clips)...

Thanks.

_________________
Phil "Philpem" Pemberton
http://www.philpem.me.uk/


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 17, 2005 5:33 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
Hi Phil,

I tested the code on my Simulator. Here is what I did:

I relabeled the *=$1000 to *=$9000 and *=$1500 to *=$9600.
I also modified the three calls to the system IO routines to match those of my Simulator:
syskin jmp $E821 ; Sim's get a key routine
syschout jmp $E824 ; Sim's chr ouput routine
syshexout jmp $E812 ; Sim's HEX byte output (Print1Byte)

these routines end with the RTS instructions so execution returns to the Microchess routine calling these adresses.

I then started the simulator and did a jump to $9000 and all worked fine. You have to type 'C' to clear the board and set up a new game. Then press 'P' to let the computer play the white move. You then enter your from & to locations followed by the <Enter> key. i.e. 6343<Enter>

I'm not sure why your program is stuck in a loop. Is your processor a WDC65C02, or is it another older one that might not be supporting the CMOS instructions????

Good luck!
Daryl


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 17, 2005 7:14 pm 
Offline

Joined: Tue Dec 10, 2002 11:00 am
Posts: 16
Location: West Yorkshire, UK
8BIT wrote:
Hi Phil,
I relabeled the *=$1000 to *=$9000 and *=$1500 to *=$9600.
I also modified the three calls to the system IO routines to match those of my Simulator:
syskin jmp $E821 ; Sim's get a key routine
syschout jmp $E824 ; Sim's chr ouput routine
syshexout jmp $E812 ; Sim's HEX byte output (Print1Byte)

these routines end with the RTS instructions so execution returns to the Microchess routine calling these adresses.
I then started the simulator and did a jump to $9000 and all worked fine.


Hmm. Looks like I need to get my 65C02S inverse assembler (for my HP1651B logic analyser) working then...

Quote:
You have to type 'C' to clear the board and set up a new game. Then press 'P' to let the computer play the white move. You then enter your from & to locations followed by the <Enter> key. i.e. 6343<Enter>


Well, that explains why the board looked like.. well.. like two people had decided to play "House Rules Chess, Anything Goes Variation"

Quote:
I'm not sure why your program is stuck in a loop. Is your processor a WDC65C02, or is it another older one that might not be supporting the CMOS instructions????


It's a WDC W65C02SP, running at 8MHz, with a GAL16V8 for address decoding. The UART card is a TI TL16C550, a Maxim quad linedriver (yes, all the handshaking pins work, except RI) and a GAL.

Thanks.

_________________
Phil "Philpem" Pemberton
http://www.philpem.me.uk/


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 17, 2005 8:00 pm 
Offline

Joined: Tue Dec 10, 2002 11:00 am
Posts: 16
Location: West Yorkshire, UK
8BIT wrote:
I relabeled the *=$1000 to *=$9000 and *=$1500 to *=$9600.

Wait.. $1500? The version I've got (from 6502.org) uses $1580...

_________________
Phil "Philpem" Pemberton
http://www.philpem.me.uk/


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 17, 2005 9:28 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
philpem wrote:
8BIT wrote:
I relabeled the *=$1000 to *=$9000 and *=$1500 to *=$9600.

Wait.. $1500? The version I've got (from 6502.org) uses $1580...


Yes, you are right. I too am not using the IO routines included in the program as my SBC and Sim already have the IO routines. I had moved the $1580 block down to $1500 to reduce the gap caused be the removed code.

Daryl


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 17, 2005 10:37 pm 
Offline

Joined: Tue Dec 10, 2002 11:00 am
Posts: 16
Location: West Yorkshire, UK
8BIT wrote:
philpem wrote:
8BIT wrote:
I relabeled the *=$1000 to *=$9000 and *=$1500 to *=$9600.

Wait.. $1500? The version I've got (from 6502.org) uses $1580...


Yes, you are right. I too am not using the IO routines included in the program as my SBC and Sim already have the IO routines. I had moved the $1580 block down to $1500 to reduce the gap caused be the removed code.

Daryl


Why bother with the *=$1500 at all? Why not just leave the data chunk to follow on from the code?

In any case, I've got it mostly working now. It displays a perfectly sane chess board, then when I press "C", it redraws the white side fine. When it gets to the black side, it gives me this output:
Code:
------------------------
|  |**|  |**|  |**|  |**|50
------------------------
|BP|BP|B|B|B-------------------------
?

... followed by a BELL from the terminal (usually only output when it receives an ASCII "BEL" character, #$07 iirc)

If I reset the 6502, I get the slightly more sane:
Code:
------------------------
|**|WC|**|  |**|BP|**|  |60
------------------------
|B|**|  |**|  |WP|  |**|70
------------------------
 00 01 02 03 04 05 06 07
4A 79 4E
?


Which includes the "LED" display, but still looks mad...
I'm now using a raw copy of the code from http://home.surewest.net/dnh/downloads.html, with the SYSHEXOUT routine from the 6502.org version.

Thanks.

_________________
Phil "Philpem" Pemberton
http://www.philpem.me.uk/


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sat Dec 17, 2005 11:09 pm 
Offline

Joined: Tue Dec 10, 2002 11:00 am
Posts: 16
Location: West Yorkshire, UK
Oh, I'm such an idiot...

Quote:
; BLOCK DATA
*= $C500
SETW .byte $03, $04, $00, $07, $02, $05, $01, $06


That *= was making my assembler trample all over the last few bytes of the lookup table that stored the chess piece characters ("WP", "WC" and so forth). Moving the *= up to C600 fixed the bug. It wastes about 250 bytes of code, but at least MC works now :)

Now to try and remember how to play chess, and maybe build up that M/IO board I've been promising myself. IDE hard drive, 3.5" floppy, realtime clock and LCD interface, all on one board. Very cool :)

Thanks.

_________________
Phil "Philpem" Pemberton
http://www.philpem.me.uk/


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 18, 2005 5:01 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1747
Location: Sacramento, CA
Phil,

Glad to see you found the trouble. You are right, you probably don't even need that *=..... hind sight....

Good luck with the I/O board. I'm 80% done with a Fat16 compatible file system driver for IDE HD and CF cards... and 50% done with the Ethernet driver...

To quote Mr Scott,... " I need for time captain!"

Merry Christmas to all!!!!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: dmrogers99 and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: