News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_cperezgrin

[CPCTELERA] Looking for extra bytes

Started by cperezgrin, 19:58, 14 October 18

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cperezgrin

Hi everybody, what is the highest value address for a cpctelera project to run properly? I have seen after loading a dsk file, around A700 starts to be some values instead of 0's. Are they the firmware variables you're talking in another thread? Is there a way to use those addresses and make my project larger?
When my project is around A900, I got loading error.
Thanks

ervin


Docent

#2
Quote from: cperezgrin on 19:58, 14 October 18
Hi everybody, what is the highest value address for a cpctelera project to run properly? I have seen after loading a dsk file, around A700 starts to be some values instead of 0's. Are they the firmware variables you're talking in another thread? Is there a way to use those addresses and make my project larger?
When my project is around A900, I got loading error.
Thanks

If you going to load anything from disk, its #A6FB - from #A6FC start various system reserved variables, buffers and vectors. If you don't need system you can use the area up to #BFFF (minus some space for the stack) but you wont be able to load such file from disk - the loaded file can not cross #A6FC boundary.

cperezgrin

#3
thaks, that was the limit I was looking for. I will try some tips I watched from ronaldo's videos.
Is there any custom clear_screen function that doesn0t clear the spare bytes? So I can used it.
Meanwhile I will use drawsolidbox

Docent

#4
Quote from: cperezgrin on 08:58, 15 October 18
thaks, that was the limit I was looking for. I will try some tips I watched from ronaldo's videos.
Is there any custom clear_screen function that doesn0t clear the spare bytes? So I can used it.
Meanwhile I will use drawsolidbox

The limit I mentioned is not located in video memory. Video memory usually starts from #C000 to #FFFF and the spare bytes are at the end of each 2kb block ie. #C7D0, CFD0, D7D0, DFD0 etc.  You can clear it, preserving the spare bytes with some asm code like this:

clearscr:
ld hl, #c000
ld de, #c001
ld b, 8
xor a
copyloop:
ld (hl), a
push bc
ld bc, #7cf
ldir
ld bc, #31
add hl, bc
ex de, hl
add hl, bc
ex de, hl
pop bc
djnz copyloop
ret



cperezgrin

Thanks, I will see how much large is this function and use it if is smaller than mine using drawsolidbox (49 Bytes). As I'm looking only for space not CPU cycles.

Docent

Quote from: cperezgrin on 09:23, 16 October 18
Thanks, I will see how much large is this function and use it if is smaller than mine using drawsolidbox (49 Bytes). As I'm looking only for space not CPU cycles.

It is smaller - it takes 26 bytes.

cperezgrin

Great, now I need to learn hot to put that asm code into cpctelera C function. Fortunately, there's a lot of ronaldo's videos to learn

Arnaud

Quote from: cperezgrin on 20:46, 16 October 18
Great, now I need to learn hot to put that asm code into cpctelera C function. Fortunately, there's a lot of ronaldo's videos to learn
If needed tell me.

cperezgrin

I managed to make it work, but had to change some values
void borrarPantalla(){
    __asm
        ld     hl, #0xC000
        ld     de, #0xC001
        ld     b, #0x08
        xor     a
    copyloop:
        ld     (hl), a
        push     bc
        ld     bc, #0x07CF
        ldir
        ld     bc, #0x0031
        add     hl, bc
        ex     de, hl
        add     hl, bc
        ex     de, hl
        pop     bc
        djnz     copyloop
    __endasm;
}

Docent

Quote from: cperezgrin on 20:14, 17 October 18
I managed to make it work, but had to change some values


well spotted, it should be #31 not #40, of course.

ronaldo

Quote from: cperezgrin on 20:46, 16 October 18
Great, now I need to learn hot to put that asm code into cpctelera C function. Fortunately, there's a lot of ronaldo's videos to learn
When including assembly in your projects, it is much preferable no to embed it into C functions. It is much preferable to place it in its own assembly .s file. Put the code in a .s file below your src folder and it will be automatically compiled and linked in your binary. You only need 2 details:

  • The label at the front of the code neets to be prefixed with an underscore. All C global symbols are prefixed that way. So, your label should be called _borrarPantalla.
  • C compiler needs to know the function prototype to be able to produce de call. You only need to add a declaration of the function before using it. In this case, void borrarPantalla();. That's enough for C to know the label of the function, the parameters and their types (none) and the return type (void).

With respect to firmware limits, loaders and placing code in different parts of memory, I discussed it in these monday's lessons and will be available on youtube tomorrow. I didn't specify exact memory addresses for buffers because that's less relevant when creating an own loader. For that, @Docent has given you the exact information.

Another question would be if you actually need to clear the screen. In many cases is much reasonable to redraw only things that change. Other times you want to redraw everything (for instance, when you are software-scrolling) but then it is unnecesary to clear the screen. Have you actually considered if it is really necessary for you to clear the screen?

Hope it helps. 

GUNHED

Can cpctelera use expansion RAM? Maybe that's a way.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

cperezgrin

I use the clear screen because I don't use background. So it's easier to have a clear screen for my purpose, more if Docent designed this very light one. (Thanks again)

Converting the C functions to asm (.s) was the first thing I did today ;D , as I read how to do it in another post  with your guideline (http://www.cpcwiki.eu/forum/programming/sdcc-3-6-8-(cpctelera-1-4-2)-assembly-compilation-problem/). I want to do it because I also had another one with parameters, and in that case, compiling throws warnings for the "unused" parameters that I wanted to clear.
I'll be expecting that new masterclass about #memory

GUNHEAD, I don't contemplate a RAM expansion, I want my project to work in a 64KB machine (464)
Bye and many thanks for all your posts, I'm learning a lot from them.

ronaldo

Quote from: GUNHED on 16:21, 18 October 18
Can cpctelera use expansion RAM? Maybe that's a way.
#CPCtelera can do anything you can do as a programmer. It is a framework, not an abstraction layer.

Quote from: cperezgrin
I use the clear screen because I don't use background. So it's easier to have a clear screen for my purpose, more if Docent designed this very light one. (Thanks again)
If you are using a solid background, have you considered clearing only those sprites that move from one frame to the other? Or even better, have you considered using sprites with a background-coloured frame so as they remove their own trail as they are redrawn?

Those are always interesting possibilities, because clearing the whole screen is quite expensive in terms of CPU usage.

cperezgrin

When the game is playing I use the process you're talking about, erase & paint the moving sprites. But when I need a totally new screen, changing between levels, back to menu, ... it's easier a clear screen, as it only costs a few bytes and the CPU usage it's not important in that moment because the game isn't playing.

ronaldo

That makes perfect sense. I thought you were clearing the screen to redraw every new frame, hence my questions and suggestions.

Good luck with the rest of your project :)

Powered by SMFPacks Menu Editor Mod