New screen / pixel editor for VIC-20

Basic and Machine Language

Moderator: Moderators

a1bert
Vic 20 Dabbler
Posts: 96
Joined: Mon Jan 23, 2006 12:49 am

Post by a1bert »

adric22 wrote:For example, many of the CMP instructions I use, even if comparing to #$00 is to help me look at the code and see what is going on.
What I do is keep the unnecessary instructions in comments, you could do the same. For example when I optimize clc and sec instructions away (by convincing that C is always cleared / set at that point), I leave the CLC in comment and the reason why it is not needed.

Well, most of the time anyway... It helps when you come back to the code later.

-Pasi
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Screen editor ported to C64

Post by Mike »

adric22 wrote:I ported my screen editor over to the C64, which is cool because now you can edit in 80x50 pixels. Anyway, one problem I can't seem to work out is that the load/save routines don't work anymore. I didn't change anything except the length of the file to be saved (since the screen is now larger). Saving doesn't seem to save anything and loading causes the system to reset to a READY prompt.. I haven't been able to figure out why. Otherwise, everything else is working. Here are the load/save routines if anyone has any input:

Code: Select all

FILENAME	!pet "image"
SETLFS = $FFBA
SETNAM = $FFBD
LOAD = $FFD5
SAVE = $FFD8

LOADFILE 	; Uses kernel routine to load temporary screen area from disk.
	LDA	#$01
	LDX	#$08		; Device 8
	LDY	#$01
	JSR	SETLFS
	LDA	#$05
	LDX	#<FILENAME
	LDY	#>FILENAME
	JSR	SETNAM
	LDA	#$0
	JSR	LOAD
	JSR	LOADSCN	; Copy temporary area to screen memory.
	RTS

SAVEFILE	; Uses kernel routine to save temporary screen area to disk.
	JSR	PUTOLD 	; Gets the cursor off out of the image before saving.
	JSR	COPYSCN	; Copy screen to temporary area.	
	LDA	#$01
	LDX	#$08		; Device 8
	LDY	#$00
	JSR	SETLFS
	LDA	#$05
	LDX	#<FILENAME
	LDY	#>FILENAME
	JSR	SETNAM
	LDA	#<SCRTEM	; Temporary area.
	STA	$C1
	LDA	#>SCRTEM	; Temporary area.
	STA	$C2
	LDA	#$C1
	LDX	#<SCRTEM+$05DC ;end of Temporary area.
	LDY	#>SCRTEM+$05DC ;end of Temporary area.
	JSR	SAVE
	RTS
There are no obvious errors in the load and save routines. Please check the accompanying calls of LOADSCN, PUTOLD, and COPYSCN.
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Re: Screen editor ported to C64

Post by adric22 »

Mike wrote: There are no obvious errors in the load and save routines. Please check the accompanying calls of LOADSCN, PUTOLD, and COPYSCN.
That was my first thought as well.. but all of those routines are used elsewhere in the code and seem to be working fine.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Other than the file length is adjusted to 1500 bytes ($05DC) the routines are an exact copy of the ones used in the VIC-20 version.

You say the other routines "seem" to work fine. Check whether they write their data into the correct position for the save, and load routines. When they're used within the editor for temporary storage, and restore purpose - they can do so nearly everywhere in memory. When that data is put at a wrong position you won't notice any error, unless the data is supposed to be transferred to/from disk.
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Post by adric22 »

Mike wrote:Other than the file length is adjusted to 1500 bytes ($05DC) the routines are an exact copy of the ones used in the VIC-20 version.

You say the other routines "seem" to work fine. Check whether they write their data into the correct position for the save, and load routines. When they're used within the editor for temporary storage, and restore purpose - they can do so nearly everywhere in memory. When that data is put at a wrong position you won't notice any error, unless the data is supposed to be transferred to/from disk.
Those routines simply copy the screen to a temporary location and retrieve it. The same routines are called when you press enter to bring up the character select screen because it stores the screen, clears the screen, and redraws it after you pick your character. However, I have an idea.. I'll just try commenting out those routines and trying the load/save routines.. I'll let you know what happens.

EDIT - Same problem. So my only guess is that the load routine is loading in the file at the wrong address and screwing something up, probably because the load routine doesn't force an address and instead depends on the file's 2-byte load address on the disk.

EDIT AGAIN - Interesting.. I just noticed something. Even though I deleted the previous IMAGE.P00 files from the directory, when I actually do a LOAD"$",8 from inside VICE, it shows several files all with the same name of "IMAGE" so I suspect it is loading one of the VIC-20 files which is at a different load address.. but the question now is, where are these files coming from since I deleted them from the folder?

EDIT EVEN AGAIN - Figured it out.. I had renamed some other .P00 files but did not realize they stored the filename inside of the file. So that was the problem.. apparently the program itself has been working for some time. I'll post it on my website if anyone wants to try it out.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Seems the question is solved then ...
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Post by adric22 »

Image

download binary: http://galaxy22.dyndns.org/edit64

Yep.. here it is working on the C64. This has been a most interesting experience for me since I originally designed the program for the VIC-20. One thing I learned is that since all of the kernel routines are exactly the same, I could have actually made this program a single source code. If I had worked it this way from the beginning I could have made little snippets of code for the VIC-20 and for the C64 and could have designed it so that a small command for the compiler would have determined if you wanted to compile for the VIC-20 or C64. That would have meant in the future, adding most types of new features would be easier and would probably work on both systems. It is too late for this source code because I already reworked it and don't feel like messing with it. But in the future I may try working it that way. I wonder about the Plus/4. Hmmm.
Post Reply