C64 ML Code Thing

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

C64 ML Code Thing

Post by Darendor »

So I thought I'd try to take what's going on in the developer board and see if I couldn't write a simple ML routine for an editor.

This is what I have.

Code: Select all

[.C:c000  A9 00       LDA #$00
.C:c002  8D 21 D0    STA $D021
.C:c005  8D 20 D0    STA $D020
.C:c008  A9 20       LDA #$20
.C:c00a  9D 00 04    STA $0400,X
.C:c00d  9D 00 05    STA $0500,X
.C:c010  9D 00 06    STA $0600,X
.C:c013  9D E8 06    STA $06E8,X
.C:c016  A9 00       LDA #$00
.C:c018  9D 00 D8    STA $D800,X
.C:c01b  9D 00 D9    STA $D900,X
.C:c01e  9D 00 DA    STA $DA00,X
.C:c021  9D E8 DA    STA $DAE8,X
.C:c024  E8          INX
.C:c025  D0 E1       BNE $C008
.C:c027  18          CLC
.C:c028  A0 0B       LDY #$0B
.C:c02a  A2 00       LDX #$00
.C:c02c  20 F0 FF    JSR $FFF0
.C:c02f  A0 C3       LDY #$C3
.C:c031  A2 00       LDX #$00
.C:c033  20 D2 FF    JSR $FFD2
.C:c036  60          RTS
Text 7e = pi symbol; string end marker
c300 - c31a Inc: Bard's Tale II Item Editor

Code: Select all

.C:c300  C2 81       NOOP #$81
.C:c302  92          JAM
.C:c303  84 27       STY $27
.C:c305  93 20       SHA ($20),Y
.C:c307  D4 81       NOOP $81,X
.C:c309  8C 85 20    STY $2085
.C:c30c  C9 C9       CMP #$C9
.C:c30e  20 C9 94    JSR $94C9
.C:c311  85 8D       STA $8D
.C:c313  20 C5 84    JSR $84C5
.C:c316  89 94       NOOP #$94
.C:c318  8F 92 7E    SAX $7E92
Predictably enough, it doesn't work. :?

Any clues on what I'm doing wrong?
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 ML Code Thing

Post by Darendor »

LIttle help here.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 ML Code Thing

Post by Darendor »

Machine Language sucks.
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 ML Code Thing

Post by Weber G »

Back in the 80s? => no!

Please don't try to programm something in the old ML of the C64, it will take many weeks. But if you have to, do it with the Turbo Assembler.

Today we have much more possibilities and tool on a windows PC that can do this in a few hours => automatically!

e.g. EXCEL:
I have written a short macro that calculates each byte of the monster and item values and creates a table. => very fast
I have also written a macro that extracts a file from a d64 image by only entering the track and sector, then XOR it and display the characters. With one click, the macro XOR back the file and embeed it back in the d64 image. => very fast

It should be very easy to load the item values to EXCEL, then edit them and write them back to d64.

I would never do this in C64 ML (would cost me too much time)! Use Excel or a modern Hex-Editor under Windows. => trust me!
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 ML Code Thing

Post by Darendor »

Right, so thanks for the lecture.

Can you help me debug my ML routine here or not?
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 ML Code Thing

Post by Weber G »

Which value do you have in X at the beginning?
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 ML Code Thing

Post by Weber G »

The value of A is printed with $FFD2 on the screen. If you want to do it from an address, use LDA $C300 and not the X and Y register.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 ML Code Thing

Post by Darendor »

This is the latest iteration of the code in question.

Code: Select all

.C:c000  A9 93       LDA #$93
.C:c002  20 D2 FF    JSR $FFD2
.C:c005  A9 00       LDA #$00
.C:c007  8D 20 D0    STA $D020
.C:c00a  8D 21 D0    STA $D021
.C:c00d  A9 0E       LDA #$0E
.C:c00f  20 D2 FF    JSR $FFD2
.C:c012  A9 9B       LDA #$9B
.C:c014  20 D2 FF    JSR $FFD2
.C:c017  A2 00       LDX #$00
.C:c019  A0 07       LDY #$07
.C:c01b  18          CLC
.C:c01c  20 F0 FF    JSR $FFF0
.C:c01f  A0 00       LDY #$00
.C:c021  B9 00 C3    LDA $C300,Y
.C:c024  C0 1B       CPY #$1B
.C:c026  F0 07       BEQ $C02F
.C:c028  20 D2 FF    JSR $FFD2
.C:c02b  C8          INY
.C:c02c  4C 21 C0    JMP $C021
.C:c02f  60	     RTS


(C:$c024) > c300 c2	B
(C:$c024) > c301 41	a
(C:$c024) > c302 52	r
(C:$c024) > c303 44	d
(C:$c024) > c304 27	'
(C:$c024) > c305 53	s
(C:$c024) > c306 20	_
(C:$c024) > c307 d4	T
(C:$c024) > c308 41	a
(C:$c024) > c309 4c	l
(C:$c024) > c30a 45	e
(C:$c024) > c30b 20	_
(C:$c024) > c30c c9	I
(C:$c024) > c30d c9	I
(C:$c024) > c30e 20	_
(C:$c024) > c30f c9	I
(C:$c024) > c310 54	t
(C:$c024) > c311 45	e
(C:$c024) > c312 4d	m
(C:$c024) > c313 20	_
(C:$c024) > c314 c5	E
(C:$c024) > c315 44	d
(C:$c024) > c316 49	i
(C:$c024) > c317 54	t
(C:$c024) > c318 4f	o
(C:$c024) > c319 52	r
When you run it, it appears to work, then gets to printing "Bard'", then hangs, then undoes the borders and screen colour changes and reverts to uppercase, prints the rest of the string, then behaves as if RUN/STOP & RESTORE had been pressed.

The hell is going on? :?
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 ML Code Thing

Post by Darendor »

Keeping the data string intact, I tried it with only this:

Code: Select all

.C:c01f  A0 00       LDY #$00
.C:c021  B9 00 C3    LDA $C300,Y
.C:c024  C0 1B       CPY #$1B
.C:c026  F0 07       BEQ $C02F
.C:c028  20 D2 FF    JSR $FFD2
.C:c02b  C8          INY
.C:c02c  4C 21 C0    JMP $C021
.C:c02f  60	     RTS
I switched to lowercase mode before executing it with G C000, and guess what? It reverted to uppercase/GFX mode, printed it, and then behaved as if RUNSTOP/RESTORE had been hit.

:?
Oh and the addresses were modified accordingly. :roll:
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 ML Code Thing

Post by Darendor »

So...

I saved the code in the WinVICE monitor thingy, and then loaded it and ran it from the BASIC interpreter with SYS49152.

It worked perfectly.

:shock:

Which for some reason only annoyed me further. :?
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 ML Code Thing

Post by Darendor »

Any hints on how to read a track/sector from disk using ML? :?
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 ML Code Thing

Post by Weber G »

You can do it as in BT2 directly via CIA.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 ML Code Thing

Post by Darendor »

Weber G wrote: Sun Jan 24, 2021 3:58 pm You can do it as in BT2 directly via CIA.
I somehow doubt that the Central Intelligence Agency can help me with this.

Care to elaborate?
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: C64 ML Code Thing

Post by Weber G »

I somehow doubt that the Central Intelligence Agency can help me with this.
:D Maybe the CIA 6526 (Complex Interface Adapter).....

Search for the user port acces via $DD00 then you will find a way to load directly from track/ sector.

You can also analyse the BT2 code beginning with $0200. As far as I know, there is no kernal function to access the track/ sector without using a file name.

If you know how it works at BT2, you can use the routines from the game to load directly from track/ sector. Unfortunately the BT2 routines are located in the kernal memory, so you have to move them...
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: C64 ML Code Thing

Post by Darendor »

Weber G wrote: Sun Jan 24, 2021 5:13 pm
I somehow doubt that the Central Intelligence Agency can help me with this.
:D Maybe the CIA 6526 (Complex Interface Adapter).....

Search for the user port acces via $DD00 then you will find a way to load directly from track/ sector.

You can also analyse the BT2 code beginning with $0200. As far as I know, there is no kernal function to access the track/ sector without using a file name.

If you know how it works at BT2, you can use the routines from the game to load directly from track/ sector. Unfortunately the BT2 routines are located in the kernal memory, so you have to move them...
Well it's a good thing my game has filenames then.

I dunno how to search for the user port access via DD00. What does that even mean?
Post Reply