Jump to content

0

Sketch template


6 replies to this topic

#1 Ninjabba ONLINE  

Ninjabba

    Moonsweeper

  • 499 posts
  • Location:Lurking in the Darkness

Posted Tue Sep 28, 2010 3:50 PM

I'm trying to extend the template from karri with my own module (http://www.breitband...rt-demo-1.1.zip), because it looks like memory is managed very effectively in here compared to my own project. However, I think I'm missing a detail on how to extend this, because I can't get it to work..

I have a folder called 'world' with a file called 'map.c' and 'map.h'. I compile the files using the same segments as for the provided 'sketch' folder (using BANK7 as memory in lynxcart.cfg). I extended the directory.s file as described with
	.import __WORLD_CODE_LOAD__
	.import __WORLD_CODE_SIZE__
	.import __WORLD_DATA_SIZE__
	.import __WORLD_RODATA_SIZE__

and
; The 3rd entry is the 1st game level we want to run.

entry off2, len2, off3, block3, len3, __SKETCH_CODE_SIZE__+__SKETCH_RODATA_SIZE__+__SKETCH_DATA_SIZE__, __SKETCH_CODE_LOAD__



entry off3, len3, off4, block4, len4, __WORLD_CODE_SIZE__+__WORLD_RODATA_SIZE__+__WORLD_DATA_SIZE__, __WORLD_CODE_LOAD__


Now the compiler (cc65) complains about the WORLD_CODE_SIZE etc. to be undefined externals. I can't find out where to fix this. Also, I haven't figured out how to load a new module in resident.c. FileLoadFile uses INTRO_FILENR and SKETCH_FILENR to load new modules, and they are defined in resident.h (as 2 and 3). Adding
#define WORLD_FILENR 4 
is of course not enough, but I don't know where this definition is used again.

Any ideas on how to do this correctly?

#2 Shawn Jefferson OFFLINE  

Shawn Jefferson

    Stargunner

  • 1,678 posts
  • Location:Victoria, Canada

Posted Tue Sep 28, 2010 10:49 PM

You should have WORLD_CODE, WORLD_RODATA, WORLD_DATA as segments in your linker config file.  It sounds you don't.

#3 Ninjabba ONLINE  

Ninjabba

    Moonsweeper

  • 499 posts
  • Location:Lurking in the Darkness

Posted Wed Sep 29, 2010 2:09 AM

Ah, totally overlooked that part. But for me it only solves part of the problem. Adding the segments
	WORLD_CODE: load = BANK7, type = ro, define = yes;
	WORLD_RODATA: load = BANK7, type = ro, define = yes;
	WORLD_DATA: load = BANK7, type = rw, define = yes;
	WORLD_BSS: load = BANK7, type = bss, optional = yes;
to the config file makes some undefined external errors to dissapear, but for some reason I still get this:

ld65: Warning: lynxcart.cfg(40): Segment `WORLD_RODATA' does not exist
Unresolved external `__WORLD_RODATA_SIZE__' referenced in:
  directory.s(30)

WORLD_RODATA: load = BANK7, type = ro, define = yes; is written on line 40 in lynxcart.cfg

#4 Ninjabba ONLINE  

Ninjabba

    Moonsweeper

  • 499 posts
  • Location:Lurking in the Darkness

Posted Wed Sep 29, 2010 3:47 AM

Debugged for an hour on the train just now.. looks like its working!

#5 Ninjabba ONLINE  

Ninjabba

    Moonsweeper

  • 499 posts
  • Location:Lurking in the Darkness

Posted Thu Oct 7, 2010 3:54 AM

I've been working with this template for a while now, but still I have a few questions on the memory layout..

If I look at the binaries of existing ROMS, they all have sizes of 128 to 512kb, so I assume I can put a similar amount of data in one ROM as well. The Lynx provides me with 64kb of RAM memory, and I thought with the template I could load segments of code/data into specified memory areas and overwrite these whenever I want to load a new module.
So what I have now is the following segments:

	# Worldmap screen
	WORLD_CODE: load = BANK2, type = ro, define = yes;
	WORLD_RODATA: load = BANK2, type = ro, define = yes;
	WORLD_DATA: load = BANK2, type = rw, define = yes;
	WORLD_BSS: load = BANK2, type = bss, optional = yes;

	# Battle screen
	BATTLE_CODE: load = BANK7, type = ro, define = yes;
	BATTLE_RODATA: load = BANK7, type = ro, define = yes;
	BATTLE_DATA: load = BANK7, type = rw, define = yes;
	BATTLE_BSS: load = BANK7, type = bss, optional = yes;

the idea is that one moment you are on the worldmap, and the next moment you jump to a battle screen (they can be interpreted as two 'separated games' with nothing in common). I have them assigned to the following memory sections:

	BANK2: start = $3000, size = $5000, define = yes, file = %O;
	BANK7: start = $3000, size = $5000, define = yes, file = %O;

but running this gives me the warning in handy:
C65C02::Update() - Illegal opcode(44) at PC=$3122

This happens when I'm on the worldmap and it jumps to the battle screen.

Clearly I'm doing something wrong. I hope someone can help me out with this problem.. I have all parts of my game written already, but cant fit it all together...

Edited by Ninjabba, Thu Oct 7, 2010 3:55 AM.


#6 matashen OFFLINE  

matashen

    Moonsweeper

  • 448 posts

Posted Thu Oct 7, 2010 11:13 AM

View PostNinjabba, on Thu Oct 7, 2010 3:54 AM, said:

I've been working with this template for a while now, but still I have a few questions on the memory layout..

If I look at the binaries of existing ROMS, they all have sizes of 128 to 512kb, so I assume I can put a similar amount of data in one ROM as well. The Lynx provides me with 64kb of RAM memory, and I thought with the template I could load segments of code/data into specified memory areas and overwrite these whenever I want to load a new module.
So what I have now is the following segments:

	# Worldmap screen
	WORLD_CODE: load = BANK2, type = ro, define = yes;
	WORLD_RODATA: load = BANK2, type = ro, define = yes;
	WORLD_DATA: load = BANK2, type = rw, define = yes;
	WORLD_BSS: load = BANK2, type = bss, optional = yes;

	# Battle screen
	BATTLE_CODE: load = BANK7, type = ro, define = yes;
	BATTLE_RODATA: load = BANK7, type = ro, define = yes;
	BATTLE_DATA: load = BANK7, type = rw, define = yes;
	BATTLE_BSS: load = BANK7, type = bss, optional = yes;

the idea is that one moment you are on the worldmap, and the next moment you jump to a battle screen (they can be interpreted as two 'separated games' with nothing in common). I have them assigned to the following memory sections:

	BANK2: start = $3000, size = $5000, define = yes, file = %O;
	BANK7: start = $3000, size = $5000, define = yes, file = %O;

but running this gives me the warning in handy:
C65C02::Update() - Illegal opcode(44) at PC=$3122

This happens when I'm on the worldmap and it jumps to the battle screen.

Clearly I'm doing something wrong. I hope someone can help me out with this problem.. I have all parts of my game written already, but cant fit it all together...

Iam not sure, but i think that
you have both banks in the same memory section.
So the code that you load overwrites the running code.
make a loader on a seperate bank, that loads in the same bank or work with two banks

Regards
Matthias

#7 Ninjabba ONLINE  

Ninjabba

    Moonsweeper

  • 499 posts
  • Location:Lurking in the Darkness

Posted Fri Oct 8, 2010 4:34 AM

Overwriting the running code is exactly what I want to achieve. That way I could use more than just 64kb of data for my game. But I seem to have found the issue.. I was using an external variable in Battle which was located in World. I really should write out some flow-chart here... and stop coding around 4am




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users