Author Topic: Basic loader  (Read 1495 times)

0 Members and 1 Guest are viewing this topic.

Online reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 947
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
  • Liked: 1720
  • Likes Given: 953
Basic loader
« on: 09:06, 24 October 18 »
I'm trying to make a pure basic loader that works both cassette and disc, and DSK works fine but the CDT loads the loading screen "displaced" and I don't know why.

My idea is pure basic, load the palette, set the colours with INK, load the image into 0xc000, and finally load the game.

The loader is:

Code: [Select]
10 MODE 0:CLS
20 MEMORY &9FFF:LOAD"!pal":BORDER 0
30 FOR i=0 TO 15
40 v=PEEK(i+&A000):INK i, v, v
50 NEXT i
60 LOAD"!loading"
70 RUN"!game"

And the DSK created with idsk works as expected, but when I create a CDT with:

Code: [Select]
2cdt -n -r MYGAME loader.bas master.cdt
2cdt -F 2 -L 0xa000 -r PAL pal master.cdt
2cdt -F 2 -L 0xc000 -r LOADING loading master.cdt

For some reason the loading screen loads like this:

 

* Screenshot_2018-10-24_07-02-44.png
(3.42 kB, 761x562 - viewed 337 times)


I'm attaching the resulting CDT (doesn't include the game).

Any ideas what I'm doing wrong? Thanks!
« Last Edit: 09:08, 24 October 18 by reidrac »
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Offline pelrun

  • Supporter
  • 6128 Plus
  • *
  • Posts: 708
  • Country: au
    • index.php?action=treasury
  • Liked: 381
  • Likes Given: 245
Re: Basic loader
« Reply #1 on: 09:31, 24 October 18 »
If the "loading" binary is definitely identical between the two versions, then maybe the loading address set in the CDT isn't right. What happens if you explicitly specify the load address with the following?
Code: [Select]
LOAD"!loading",&C000

Online reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 947
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
  • Liked: 1720
  • Likes Given: 953
Re: Basic loader
« Reply #2 on: 09:35, 24 October 18 »
If the "loading" binary is definitely identical between the two versions, then maybe the loading address set in the CDT isn't right. What happens if you explicitly specify the load address with the following?
Code: [Select]
LOAD"!loading",&C000

No change. I put it in the header because it makes the basic code s bit shorter.

I suspect that 2cd may be doing something funny, but I can't tell what is it. Unless I'm missing something obvious in the behaviour of load...
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Offline cperezgrin

  • CPC464
  • **
  • Posts: 30
  • Country: es
  • Liked: 15
  • Likes Given: 5
Re: Basic loader
« Reply #3 on: 09:52, 24 October 18 »
Hi reidrac, 2cdt has a little bug. The first 69 bytes cannot be 0s. I learnt that recently, although my result was no loading screen printed. But maybe you get another result, check that.

Online reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 947
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
  • Liked: 1720
  • Likes Given: 953
Re: Basic loader
« Reply #4 on: 10:18, 24 October 18 »
Hi reidrac, 2cdt has a little bug. The first 69 bytes cannot be 0s. I learnt that recently, although my result was no loading screen printed. But maybe you get another result, check that.

I'll look at this. I may be able to fix it :+1:
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2278
  • Likes Given: 3478
Re: Basic loader
« Reply #5 on: 11:18, 24 October 18 »

Hi reidrac, 2cdt has a little bug. The first 69 bytes cannot be 0s. I learnt that recently, although my result was no loading screen printed. But maybe you get another result, check that.
Thank you. I will fix that.


2cdt tries to be helpful and detect an amsdos header.


In this case, I think it detects there is a header when there is no header. I will make a better header detection :)





My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline pelrun

  • Supporter
  • 6128 Plus
  • *
  • Posts: 708
  • Country: au
    • index.php?action=treasury
  • Liked: 381
  • Likes Given: 245
Re: Basic loader
« Reply #6 on: 12:08, 24 October 18 »
I can confirm it's definitely because 2CDT is trying to autodetect an AMSDOS header by calculating the checksum. Since the AMSDOS checksum is *actually* a trivial sum of the first 67 bytes, 69 zeroes is therefore a valid AMSDOS header and gets trimmed by 2cdt. Oops.
« Last Edit: 14:38, 24 October 18 by pelrun »

Offline GUNHED

  • 6128 Plus
  • ******
  • Posts: 2.316
  • Country: de
  • Reincarnation of TFM
    • FutureOS - The quickest OS for the CPC and Plus
  • Liked: 1073
  • Likes Given: 2610
Re: Basic loader
« Reply #7 on: 17:31, 24 October 18 »
In this case, I think it detects there is a header when there is no header. I will make a better header detection :)


Well, that's a general problem. If the header is 0 then the checksum is 0. So a header is detected where no header is there. Had that problem with FutureOS before. Just check if the sum of all header bytes is zero, in this case define "it's not a header".  :)
http://futureos.de --> Get the revolutionary FutureOS (Recent update: 2021.01.24)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.02.18)

Offline ronaldo

  • Dev
  • 6128 Plus
  • *****
  • Posts: 648
  • Country: es
    • Profesor Retroman
  • Liked: 941
  • Likes Given: 827
Re: Basic loader
« Reply #8 on: 17:32, 24 October 18 »
Hi reidrac, 2cdt has a little bug. The first 69 bytes cannot be 0s. I learnt that recently, although my result was no loading screen printed. But maybe you get another result, check that.

Yes, that's exactly what I was going to say. Some of my students had this issue with their basic-made loaders. In fact, their issue was worse, because their loaders sometimes displayed nothing, and other times simply failed. It seems that this problem was long time unspot because having 69 consecutive zeroes at the start is quite unusual, and seems to be easier to get it with test images like @reidrac 's or the ones that used my students.

Thank you. I will fix that.
2cdt tries to be helpful and detect an amsdos header.
In this case, I think it detects there is a header when there is no header. I will make a better header detection :)

I think I have to apologize, @arnoldemu , I should have sent you a report when we found this issue. In fact, I think I should extend my apologizes to everyone, because this issue could have been fixed long ago if I had reported it to you. Sorry about that.

Online reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 947
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
  • Liked: 1720
  • Likes Given: 953
Re: Basic loader
« Reply #9 on: 17:58, 24 October 18 »
I never got this issue because I usually include the palette at the beginning of the image + compression. Oh, well.

@arnoldemu what is the official URL for the tool? Thanks.
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Online reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 947
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
  • Liked: 1720
  • Likes Given: 953
Re: Basic loader
« Reply #10 on: 19:00, 24 October 18 »
Yep, confirmed. That was the issue.

Thanks everybody for your help!
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2278
  • Likes Given: 3478
Re: Basic loader
« Reply #11 on: 21:05, 24 October 18 »
I never got this issue because I usually include the palette at the beginning of the image + compression. Oh, well.

@arnoldemu what is the official URL for the tool? Thanks.
http://cpctech.cpc-live.com/download/2cdt.zip
I have also updated it.
I must apologise because in my other tools I have much better header detection and I failed to transfer that into 2cdt.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Online reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 947
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
  • Liked: 1720
  • Likes Given: 953
Re: Basic loader
« Reply #12 on: 21:10, 24 October 18 »
http://cpctech.cpc-live.com/download/2cdt.zip
I have also updated it.
I must apologise because in my other tools I have much better header detection and I failed to transfer that into 2cdt.

Thanks!

I may put my bits on a repo with all together to make it easier to use, kind of like cpctelera does, but I'd love to mention the official download in case anyone wants a newer version of the tool.

Also no need to apologize. This is software and it may have bugs. You gave us your tool as a gift, and I'm thankful for it!
« Last Edit: 21:12, 24 October 18 by reidrac »
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.

Online reidrac

  • Supporter
  • 6128 Plus
  • *
  • Posts: 947
  • Country: gb
  • Trying to gamedev!
    • index.php?action=treasury
    • usebox.net
  • Liked: 1720
  • Likes Given: 953
Re: Basic loader
« Reply #13 on: 19:50, 25 October 18 »
OK, I put it all together in this repo:

https://github.com/reidrac/cpc-mastering

It focuses on Linux and it is mostly information (plus some convenient tools).

Nothing new I think, but getting this information together is not easy. It may be useful!
Released The Return of Traxtor, Golden Tail, Magica, The Dawn of Kernel, Kitsune`s Curse and Brick Rick for the CPC.

If you like my games and want to show some appreciation, you can always buy me a coffee.