Author Topic: create good cpr for gx4000  (Read 1228 times)

0 Members and 1 Guest are viewing this topic.

Offline dub

  • CPC464
  • **
  • Posts: 9
  • Country: fr
  • Liked: 11
create good cpr for gx4000
« on: 10:46, 23 September 16 »
Hi, I want to initialize the gx4000 for my cpc+ game.

It's working on cpc+ format disk but not cpr.

Arnoldemu give met his code to initialize the gx4000 but I can't make it works.
Unofficial Amstrad WWW Resource
Code: [Select]
;; This example shows a suggested startup for a cartridge

;; cartridge page 0 exists at &0000-&3fff
;; execution starts at &0000
;;
org &0000

start:

di ;; disable interrupts
im 1 ;; set interrupt mode 1
ld bc,&f782 ;; setup initial PPI port directions
out (c),c
ld bc,&f400 ;; set initial PPI port A (AY)
out (c),c
ld bc,&f600 ;; set initial PPI port C (AY direction)
out (c),c

ld bc,&7fc0 ;; set initial RAM configuration
out (c),c

;; unlock ASIC so we can access ASIC registers
ld b,&bc
ld hl,sequence
ld e,17
seq:
ld a,(hl)
out (c),a
inc hl
dec e
jr nz,seq

;; set initial CRTC settings (screen dimensions etc)
ld hl,end_crtc_data
ld bc,&bc0f
crtc_loop:
out (c),c
dec hl
ld a,(hl)
inc b
out (c),a
dec b
dec c
jp p,crtc_loop

ld hl,&c9fb
ld (&0038),hl
ei

;; enable asic ram (will be visible in range &4000-&7fff)
ld bc,&7fb8
out (c),c

;; your code here
loop:


jr loop

;; your crtc setup values here; these are examples
crtc_data:
defb &3f, &28, &2e, &8e, &26, &00, &19, &1e, &00, &07, &00,&00,&30,&00,&c0,&00
end_crtc_data:

;; sequence to unlock asic
sequence:
defb &ff,&00,&ff,&77,&b3,&51,&a8,&d4,&62,&39,&9c,&46,&2b,&15,&8a,&cd,&ee

end
What am I doing :

I add this little code in the loop: for adding color border, just for testing
Code: [Select]
LD        BC,#7F10
OUT      (C),C
LD        A,76
OUT      (C),A

I use winape for testing. And I have a black screen when I launch the cartridge.
If I launch an other cartridge before, and lauch my cartridge, I have red border.

I use two way for testing :

Directly in winape with a :
WRITE DIRECT 0,-1,&C0

or with the software cprtools after making the bin in winape with a : WRITE "cart.bin"

I certainly doing something wrong.


Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.331
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2233
Re: create good cpr for gx4000
« Reply #1 on: 15:11, 23 September 16 »
Ok there is a bug in the code. Sorry my mistake.

The EI is enabling the interrupts and the default interrupt for im 1 is 0038.

Change it to this:

Code: [Select]
org &0000
jp start
org &0038
ei
ret
start:

di ;; disable interrupts
im 1 ;; set interrupt mode 1
ld bc,&f782 ;; setup initial PPI port directions.
.
.
.

and it'll work better.

You should change the mainloop and things to call your code.
You can copy your code into ram, disable the roms and then take over the hardware :)


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

Offline Xifos

  • CPC6128
  • ****
  • Posts: 164
  • Country: fr
  • Liked: 222
Re: create good cpr for gx4000
« Reply #2 on: 16:12, 23 September 16 »
dub, it 's great to see you coding on the gx/cpc+ !
 :)
Thanks for helping him, arnoldemu !
 ;)

Offline dub

  • CPC464
  • **
  • Posts: 9
  • Country: fr
  • Liked: 11
Re: create good cpr for gx4000
« Reply #3 on: 17:51, 23 September 16 »
Thanks, I'll try this and make a test on gx4000

@Xifos : I'm just beginning, I need to rise my knowledge of the specificity of the hardware.  After I'll try to make a little game.

Offline dub

  • CPC464
  • **
  • Posts: 9
  • Country: fr
  • Liked: 11
Re: create good cpr for gx4000
« Reply #4 on: 12:11, 24 September 16 »
I "almost" succeeded  ;D

On the winape emulator, I have a good red border and my sprite. But on gx4000, I think I need to erase the ram before sending my data, as the picture show.

When I'll have a clear start, I'll begin my game dev.


The orange on the photo is red on my TV  :P

Offline Xifos

  • CPC6128
  • ****
  • Posts: 164
  • Country: fr
  • Liked: 222
Re: create good cpr for gx4000
« Reply #5 on: 13:21, 24 September 16 »
Well done !

And you are right, you need to clear memory.

The border is smaller on a tv ?
I did not know...

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.331
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2233
Re: create good cpr for gx4000
« Reply #6 on: 13:36, 24 September 16 »
I "almost" succeeded  ;D

On the winape emulator, I have a good red border and my sprite. But on gx4000, I think I need to erase the ram before sending my data, as the picture show.

When I'll have a clear start, I'll begin my game dev.


The orange on the photo is red on my TV  :P
Good that you test on a real gx4000. Always do that. :)

You can also test on my emulator if you want.
Unofficial Amstrad WWW Resource


You should assume hardware is not initialised and that you need to initialise it and clear the ram you want to use then you will have much more consistent and better results.

When testing with C4CPC you can do two things:
- connect PC to C4CPC with usb cable and run the cart direct on the C4CPC avoiding menu
- put the cpr into it's own slot and boot into that slot (select with dip switches).

If you use the menu it's possible some hardware will be initialised and you need to test it as close to "original" power on state.

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

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.331
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2233
Re: create good cpr for gx4000
« Reply #7 on: 13:38, 24 September 16 »
Well done !

And you are right, you need to clear memory.

The border is smaller on a tv ?
I did not know...
Border can be smaller or larger on CRT tv and it really depends on the television.

When developing for Wii or older consoles that can use use CRT there were instructions to tell us not to put HUD too close to the edges of the screen. (I think the "safe area" was 80% of the display).

The border should be almost the same on LCD televisions.


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

Offline gerald

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.300
  • Liked: 926
Re: create good cpr for gx4000
« Reply #8 on: 14:34, 24 September 16 »
The border is smaller on a tv ?
If you can properly read the C4CPC logo on the screen, that mean the CRCT is still configured for the cartridge selector : ie overscan.
That's why the border is so small.

Offline dub

  • CPC464
  • **
  • Posts: 9
  • Country: fr
  • Liked: 11
Re: create good cpr for gx4000
« Reply #9 on: 15:11, 24 September 16 »
Thanks
I'm used to deal with the safe area when I'm working on raspberry pi or with my 800xl.

I try try my cpr on his own slot (c4cpc) and I have only black on screen with bad frequency (or like bad screen refresh rate).
I try your emulator too and that's doesn't work. I have black left border and some color on top of the screen :  cf screenshot  :(

I continue my investigation   ;D

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.331
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2233
Re: create good cpr for gx4000
« Reply #10 on: 15:36, 24 September 16 »
Try this instead:

Unofficial Amstrad WWW Resource

There are some examples here that may help. They are better tested. My code here must be old and not working fully.

"single": Good for single files to be executed from ram.
The boot program copies the code into ram and executes it. You still need to initialise the h/w. Look at the example.

"fs": The cart is treated like a read only filesystem.
You can read and write files as you need in your program. See the example. This is much easier if your used to disks and loading files. It's similar to how a lot of C64 carts work.

"absolute": You take control over each 16KB cart page so you need to manage both your code and your data to work with it.

Maybe it is better to work with these?

You can freely use this code in your own game. I would like a credit if you use it please.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline dub

  • CPC464
  • **
  • Posts: 9
  • Country: fr
  • Liked: 11
Re: create good cpr for gx4000
« Reply #11 on: 12:45, 25 September 16 »
I'm cursed or what ?  ;D

I try the arnoldemulator and the "single" example for beginning. And I had weird results.

I use the make.bat with pasmo for Windows. Everything compil. I've just add my code to see red border.
I launch arnold emu with the gx4000 configuration as you can see on the screenshot. And When I launch the cart, I have left black border and two color lines on the top.

I try my my_cart.bin and the cpr with the cprtools.

If I insert my_cart.cpr on winape emulator, I have the game working : red border and flashing in screen. (On the bottom of my screenshot).
But I need to compiling with pasmo and after use the crptools gui. Lot of manipulation.

Offline Xifos

  • CPC6128
  • ****
  • Posts: 164
  • Country: fr
  • Liked: 222
Re: create good cpr for gx4000
« Reply #12 on: 19:46, 25 September 16 »
What does cprtools ?

Transform a bin file into a cpr file ?

Offline Kris

  • 6128 Plus
  • ******
  • Posts: 526
  • Country: fr
  • Team Impact
  • Liked: 183
Re: create good cpr for gx4000
« Reply #13 on: 22:03, 25 September 16 »
What does cprtools ?

Transform a bin file into a cpr file ?


Exactly, in both way bin => CPR or CPR=> bin