Jump to content
IGNORED

Sketch template


Ninjabba

Recommended Posts

I'm trying to extend the template from karri with my own module (http://www.breitband-anbieter.com/cc65/download/contrib/lynx-cart-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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...