[VG5000] struggling on converting binary files to k7

Cette catégorie traite de développements récents pour nos vieilles machines, applications, jeux ou démos... Amis programmeurs, c'est ici que vous pourrez enfin devenir célèbres!

Modérateurs : Papy.G, fneck, Carl

Répondre
Avatar de l’utilisateur
nitrofurano
Messages : 95
Inscription : 26 juil. 2013 15:30
Localisation : Porto
Contact :

[VG5000] struggling on converting binary files to k7

Message par nitrofurano »

hi,
as a next step on the VG5000 development, i started trying to code a binary to .k7 converter - it would embed a binary file into a .k7 image tape (i did a similar converter for zx-spectrum .tap file once) - for that converter, i used sdlBasic on Linux (later i'll recode it on Python)

http://pastebin.com/EBCM2aCg

the source and the result is in the attachment - and when i try to load the .k7 file with cload, it shows an error message "Ligne non définie" after "Trouvé:exampl"

maybe i needed to add a loader in Basic before, or enter "cload" in a different way? the idea would be about having that .bin file (compiled from Boriel's ZX-Basic Compiler) loaded and executed automatically, just like those good old games for VG5000 available in .k7 files as well

any ideas? thanks in advance! :)
Pièces jointes
example01.bin.k7.zip
(723 octets) Téléchargé 134 fois
Markerror
Messages : 2121
Inscription : 31 oct. 2011 19:21
Localisation : Orléans
Contact :

Re: [VG5000] struggling on converting binary files to k7

Message par Markerror »

Hello Paulo,

Unfortunately, the VG5000 can't execute binary files (that's seems weird, but it's like that).

Philips commercial games files are a mix of a basic file (with just the CALL &"xxxx" command) and the binary code.

Markerror
Avatar de l’utilisateur
nitrofurano
Messages : 95
Inscription : 26 juil. 2013 15:30
Localisation : Porto
Contact :

Re: [VG5000] struggling on converting binary files to k7

Message par nitrofurano »

and how these .k7 files are saved, or, how the .k7 header (including a tokenized ‘CALL &"5000"’ (or whatever) somewhere ), that i could use as a template for having it automatically gererated from a script after getting compiled binaries from any cross-compiler, whatever Boriel's ZX-Basic Compiler, z88dk (a cross-c compiler), wla-dx (a cross-assembler), etc.
Markerror
Messages : 2121
Inscription : 31 oct. 2011 19:21
Localisation : Orléans
Contact :

Re: [VG5000] struggling on converting binary files to k7

Message par Markerror »

Hi,

I spent a little time to create an example of a executable file for the VG5000. I think it may help you :-).

Markerror

; VG5000 header example
; T&J/GPA in july 2013 !

; Example of Z80 code launched automatically by a Basic CALL
; Same tchnic as the one used in commercial games from Philips
; Basic line is 10 CALL 18954 followed by asm code.

; Use WINAPE to create the K7 file, then load it in DCVG5K with
; classical CLOAD command. Press a key to clear the screen.
; No need to save HL and IX registers as the program does not
; return to Basic.

ORG &49D1
WRITE "TEST.K7"

length equ &3B ; length of the file (without header)
checksum equ &132F ; sum of datas between 'main' and 'file_footer'

; file header

db &D3,&D3,&D3,&D3,&D3,&D3,&D3,&D3,&D3,&D3,&4D,&56,&47,&35,&30,&30
db &30,&00
db &31,&30,&00,&00,&00 ; line 10 !
db &00,&00,&00,&FB,&49 ; &49FB = exec address of a Basic file
defw length
defw checksum
db &D6,&D6,&D6,&D6,&D6,&D6,&D6,&D6,&D6,&D6

; &49FB
; Basic file that calls binary code

db &00,&08,&4A,&0A,&00 ; line 10
db &9F,&31,&38,&39,&35,&34,&3A,&00 ; CALL 18954 / &4A0A
db &00,&00

; binary code
; &4A0A

main DI
LD HL,&4803
LD A,(color)
INC A
CP &8
JR NZ,main2
XOR A
main2
LD (color),A
LD C,A ; save bits 0 to 2

RLA ; rotation to set the color
RLA ; to bits 4 to 6
RLA
RLA
ADD A,C
OR &80 ; bit 7 on
LD (HL),A
CALL &9E ; should clear screen and fill it with new color

LD A,&1
LD (&47FB),A ; ask for screen refresh

EI
HALT


main1
CALL &32B7 ; scan key
AND A ; no key pressed ?
JR Z,main1
JR main

color db &00

; file_footer
db &00
Avatar de l’utilisateur
nitrofurano
Messages : 95
Inscription : 26 juil. 2013 15:30
Localisation : Porto
Contact :

Re: [VG5000] struggling on converting binary files to k7

Message par nitrofurano »

thanks! :)
Avatar de l’utilisateur
nitrofurano
Messages : 95
Inscription : 26 juil. 2013 15:30
Localisation : Porto
Contact :

Re: [VG5000] struggling on converting binary files to k7

Message par nitrofurano »

btw, based on your help, i tried what i'm sending in the attachment - tried to "cload", and it shows "Mauvais fichier"... - any clue? :S (thanks in advance again! :) )
Pièces jointes
vg5000_borielzxbasiccompiler_example01c.zip
(5.45 Kio) Téléchargé 131 fois
Avatar de l’utilisateur
nitrofurano
Messages : 95
Inscription : 26 juil. 2013 15:30
Localisation : Porto
Contact :

Re: [VG5000] struggling on converting binary files to k7

Message par nitrofurano »

btw, perhaps the "mauvais fichier" error message appears because the checksum isn't considering the tokenized-basic bytes after the 0xD6 10 bytes sequence, and "main"? so i tried to add 576 to the checksum, and the error persists...
Pièces jointes
vg5000_borielzxbasiccompiler_example01c2.zip
(5.92 Kio) Téléchargé 131 fois
Markerror
Messages : 2121
Inscription : 31 oct. 2011 19:21
Localisation : Orléans
Contact :

Re: [VG5000] struggling on converting binary files to k7

Message par Markerror »

Hi,

Gosh... You are right, the checksum must take datas from &49FB to file_footer, not main in my example...

I have fixed your test file example01.k7 and managed to load it correctly in memory.

Correct values for length and checksum are :

&15F
&9D27

When you encounter a checkum error, it display the message "Mauvais fichier"
If the length is wrong and the file too short comparing to the length value, it might just say "Trouvé <file>" then DcVG5K say that there is no more file on the K7 (not tested).

Markerror
Pièces jointes
Fixed_example01.zip
(418 octets) Téléchargé 139 fois
Avatar de l’utilisateur
nitrofurano
Messages : 95
Inscription : 26 juil. 2013 15:30
Localisation : Porto
Contact :

Re: [VG5000] struggling on converting binary files to k7

Message par nitrofurano »

yes, works! thanks! \o/ - this is a very significant goal in the cross-compiling development, at least in my humble viewpoint! :)
Pièces jointes
vg5000_borielzxbasiccompiler_example01d.zip
(6.04 Kio) Téléchargé 137 fois
Avatar de l’utilisateur
nitrofurano
Messages : 95
Inscription : 26 juil. 2013 15:30
Localisation : Porto
Contact :

Re: [VG5000] struggling on converting binary files to k7

Message par nitrofurano »

Markerror a écrit :I spent a little time to create an example of a executable file for the VG5000. I think it may help you :-).
(...)
Markerror, here in the attachment is your assembly snippet as inline-assembly into Boriel's ZX-Basic Compiler, which seems to work fine! :) - btw, do you know where from can i test more VG5000 snippets in assembly that i could use for Boriel's ZX-Basic Compiler development improvement? thanks! :)
Pièces jointes
vg5000_zxbasiccompiler_example01e_frommarkerror.zip
(5.99 Kio) Téléchargé 133 fois
Répondre