It is currently Wed May 23, 2018 1:19 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
PostPosted: Mon Jan 15, 2018 1:50 am 
Offline

Joined: Mon Mar 30, 2015 10:14 am
Posts: 254
Quote:
Why is programming taking so dang long for me nowadays?

Because you're alone,no deadlines, a project can become boring as time passes and if you want to make it best as possible, it takes time,you can add if you're like me,E.G to go in a endless optimisation you are not close to finish something easily . :wink:

I also think an original project is way more difficult(and long) to do alone rather than an adaptation.


Last edited by TOUKO on Sun Jan 21, 2018 6:56 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Jan 19, 2018 12:16 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2648
I just thought of another factor.

The more code you write, the more memory you use, and the more memory you use the more bank switching you need, and the more bank switching you do, the more complicated your code is, and the more complicated your code is, the more memory it takes up, and the more memory it takes up, the more you need bank switching.


Top
 Profile  
 
PostPosted: Fri Jan 19, 2018 1:10 pm 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 731
-> set up trampolines -> bankswitching is no longer complicated -> cycle broken


Top
 Profile  
 
PostPosted: Fri Jan 19, 2018 1:21 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 388
Location: Central Illinois, USA
calima wrote:
-> set up trampolines -> bankswitching is no longer complicated -> cycle broken


Even with trampolines, bankswitching still makes things a bit more complicated. You have to pay attention to whether a given routine or bit of data is in your current bank. Calling a trampoline'd routine is easy, but remembering whether you have to avoid a function that has no trampoline is more mental load.

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
PostPosted: Fri Jan 19, 2018 1:39 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2648
How would a trampoline code work in an SNES game?


Top
 Profile  
 
PostPosted: Sat Jan 20, 2018 2:35 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 731
gauauu wrote:
Even with trampolines, bankswitching still makes things a bit more complicated. You have to pay attention to whether a given routine or bit of data is in your current bank. Calling a trampoline'd routine is easy, but remembering whether you have to avoid a function that has no trampoline is more mental load.

Sure, but those are easily handled. Put all data a function accesses in the same file, and file-level organization now takes care of that mental load. You don't need to care about not going through a trampoline, that's needless micro-optimization until proven otherwise. Make it so that all functions are either in a common bank or trampolined, and nothing to remember.

As for SNES details, I'm not a SNES coder (yet), but if you look up my cc65 trampoline thread, RainWarrior's NES implementation may give some ideas.


Top
 Profile  
 
PostPosted: Sat Jan 20, 2018 12:47 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2648
I just moved my background tile maps to another bank, and that seemed to work.


Top
 Profile  
 
PostPosted: Sun Jan 21, 2018 2:28 am 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 426
psycopathicteen wrote:
How would a trampoline code work in an SNES game?


It wouldn't; there is 0 need for a trampoline on a 65816, unless you are dealing with a system that has more than 16MB and hence has "banks" as well. I'm sure there is some mapper system that could allow you to get into such a position if you really wanted to where you would need one, but its an edge of an edge on a vertex case ;)

But it speaks more to the general issues of complexity. Code is a Complex task that descends into Chaotic over time, so you need to spend a lot of time to "burn off the entropy" and get it back to Complex. You know those refactor periods where you rewrite a whole system or 6 over 3 weeks and then get it to the point it looks 100% the same as did before.
When you first add features, you can just hammer them in, as the goes on, you spend more time lookup existing code, making sure you havn't already made code to do a thing, make sure you don't accidentally trash something, make sure it works in all cases the game can present etc. The "checklist" for each new thing gets longer each time you add a new thing.


Top
 Profile  
 
PostPosted: Sun Jan 21, 2018 2:55 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 731
What of the data bank and program bank then? You can avoid the data bank by always using long loads, but you can't avoid the program bank. Not having to think about what jump is long and what jump is short is one of the key points of trampolines. edit: Always using long jumps and long loads is certainly possible, but I would think a trampoline design would be faster.


Top
 Profile  
 
PostPosted: Sun Jan 21, 2018 3:49 am 
Offline

Joined: Tue Feb 07, 2017 2:03 am
Posts: 426
If something is long or short - mostly the assemblers job. Working out an address based upon data bank, also the assemblers job.
Yes you will need to think, do I want this function to RTS or RTL, you could use a trampoline to do a conversion for you, but that is more a VECTOR table rather than a trampoline.
Bank 03
Code:
jLMyFunc
    jsr myFunc
    rtl

myFunc
    stuff
    rts


So if you are in Bank 02 you would do jsl jLMyFunc and if you are in Bank 03 you would do jsr myFunc not really a trampoline as you don't jump out and then bank in.
JSL takes 1 clock more than JSR
RTL takes the same number of cycles as RTS
The trampoline method eats 12 extra clocks. So if you rarely use the function out of bank, sure JUMP Vector it. If you use it 50/50 then always JSL and take the 1 clock hit.
However most of the time you can just JSR/RTS and let the assembler handle the JSL/R RTS/L conversion for you, I would think. On a SNES 32K banks are large, that is a whole C64 or NES game in one shot, In days of yore each bank would have been a "system" and had a VECTOR entry table so you could just assemble each ROM 1 by 1 and not have to sit through the whole lot each time. These days you can one shot the whole ROM and let the assembler handle it.


Top
 Profile  
 
PostPosted: Sun Jan 21, 2018 6:55 am 
Offline

Joined: Mon Mar 30, 2015 10:14 am
Posts: 254
psycopathicteen wrote:
I just thought of another factor.

The more code you write, the more memory you use, and the more memory you use the more bank switching you need, and the more bank switching you do, the more complicated your code is, and the more complicated your code is, the more memory it takes up, and the more memory it takes up, the more you need bank switching.

:lol:


Top
 Profile  
 
PostPosted: Tue Jan 23, 2018 1:08 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2648
I was thinking today, if Super Mario Bros was able to fit in 32kB, I should be able to fit the game engine code within 32kB too.


Top
 Profile  
 
PostPosted: Wed Jan 24, 2018 1:28 am 
Offline

Joined: Mon Mar 30, 2015 10:14 am
Posts: 254
psycopathicteen wrote:
I was thinking today, if Super Mario Bros was able to fit in 32kB, I should be able to fit the game engine code within 32kB too.

For 65xxx 32 kB represent a lot of space for code, so i'll say yes you can easily .
I think the good things to do is to take the game engine and all the main code in permanent mapped banks if possible, and the other stuffs (intro, menu,game over, datas ,etc ..) on classic banks which can be mapped at any times.
i don't know if this help for snes ,but i use that scheme for PCE,but it's probably more easy as PCE banks are 8kB .


Top
 Profile  
 
PostPosted: Wed Jan 24, 2018 3:04 am 
Online

Joined: Fri Jul 04, 2014 9:31 pm
Posts: 892
Why 32 kB? I can't think of a reason not to put the program bank in a HiROM region, so you can have 64 kB of solid code with no long jumps if you want.


Top
 Profile  
 
PostPosted: Wed Jan 24, 2018 9:19 am 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2648
If a routine uses a small LUT, I would like to keep it in the same bank as the routine, and be able to access it with short absolute addressing.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 68 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 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:  
Powered by phpBB® Forum Software © phpBB Group