Some things not working for me

Discussion about other targets
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

Cool! Thanks for that tip. 0.2.1 now with less memory leaks :D

Any info about the selecting different colours for mono sprites?
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I don't think there's anything yet. However, give me sometime to revisit the VZ graphics drivers and I'll see what can be done - I really should unify the block and hires graphics so that it's a run-time choice not a compile time choice.

The way I've handled colour for some other machines is to use the textcolor() and textbackground() functions to set the graphics colour - it's slightly under the hood but works well on those machines with graphics as part of the character set.
stefano
Well known member
Posts: 1534
Joined: Mon Jul 16, 2007 7:39 pm

Post by stefano »

There's also the non optimal (but handy)
Proportional font driver built for the x11 emulation.
It uses all the fonts the Sprite Editor is able to grab (NewsMaster, PrintMaster, GEOS..).

https://www.z88dk.org/forum/viewtopic.p ... 659#p14659
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Thank you for this routine - it's proving quite useful testing out targets.

I'm chasing down rabbit holes at the moment, so I'm not at the point where I can merge, however I've got the VZ code running in both screen modes including colour.

In addition to that it's running on quite a few other ports as I winkle out the bugs. So far: ZX, PC6001, RX78, PV1000, SMC777

When I'm happy I'll pass the code back to you: to get the cross platform support I've had to make a few (minor) tweaks, mostly in main.c
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

Sweet. Very excited about that. Glad it works on other platforms. I'd like to do proportional fonts but it might be a lot of work for developers to add a parameter for each character manually.

I'd like to do coloured sprites but since z88dk doesn't support that and the VZ computers have this 4 pixels power byte Crap I might have to make it VZ only and stick with moving sprites by 4 pixels left and right when moving around the screen.
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

What'd be the best way for me to do asm in my library? In the past I added vz_score and vz_bricks to 0crt.asm but should I just do it inline in my C library?
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

As mentioned above I spent a bit of time on the VZ, the MC6847 is wired up in a really weird way on this machine.

I've just merged a bunch of changes that will affect your code:

- The generic console now supports mode 1, this means that ridiculously sized 8x8 fonts are now available on the VZ
- Graphical functions now work in mode 0 and mode 1. So you need to explicitly select the mode using console_ioctl() or vz_mode(). Using console_ioctl() the CSS can in theory be set so you end up with different colours.
- The mode 1 graphics functions now support colour: set using textcolor(). I'm not convinced the mappings are 100% correct to be honest.
- Putsprite now also respects the colour configured as above

There's some changes I made last week that your code needs adapting for:

- Using the correct struct accessor: all fontspec accesses need to be via "." not "->"

Regarding your own functions - please don't add them to the crt! Keep them as files in your project: zcc can handle c files and .asm files at the same time.
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

Cool!
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

switch doesn't seem to work with constants.

Code: Select all

#define FX = 0
soundfx(FX);

Code: Select all

void soundfx(int sound) 
{
 switch(sound)
 {
  case FX:
gives an error

So does:

Code: Select all

const int FX = 0;
switch (sound) 
{
 case FX:
Only thing that works:

Code: Select all

switch (sound) 
{
 case 0:
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

Trying to use delay(x):

Code: Select all

delay(5);
Error at file 'main.c' line 1621: symbol '_delay' not defined
Errors in source file D:\Dev\VZ\z88dk\lib\config\..\..\\lib\target\vz\classic\vz_crt0.asm:
Error at file 'main.c' line 1621: symbol '_delay' not defined
^ ---- (null)
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

Tried the bit_play demo tune in the wiki:

Code: Select all

bit_play("2A--A-B-CDEFGAB5C+");
Error at file 'bit_play.c' line 496: symbol 'dmul' not defined
Error at file 'bit_play.c' line 497: symbol 'ifix' not defined
Error at file 'bit_play.c' line 506: symbol 'dswap' not defined
Error at file 'bit_play.c' line 507: symbol 'ddiv' not defined
Error at file 'bit_play.c' line 511: symbol 'dsub' not defined
Error at file 'bit_play.c' line 512: symbol 'ifix' not defined
Error at file 'z80/sccz80/int2long_s_float.asm' line 19: symbol 'float' not defined
Error at file 'z80/sccz80/int2long_s_float.asm' line 22: symbol 'float' not defined
Error at file 'z80/sccz80/fa.asm' line 12: symbol 'init_floatpack' not defined
Errors in source file D:\Dev\VZ\z88dk\lib\config\..\..\\lib\target\vz\classic\vz_crt0.asm:
Error at file 'bit_play.c' line 496: symbol 'dmul' not defined
Error at file 'bit_play.c' line 497: symbol 'ifix' not defined
Error at file 'bit_play.c' line 506: symbol 'dswap' not defined
Error at file 'bit_play.c' line 507: symbol 'ddiv' not defined
Error at file 'bit_play.c' line 511: symbol 'dsub' not defined
Error at file 'bit_play.c' line 512: symbol 'ifix' not defined
Error at file 'z80/sccz80/int2long_s_float.asm' line 19: symbol 'float' not defined
Error at file 'z80/sccz80/int2long_s_float.asm' line 22: symbol 'float' not defined
Error at file 'z80/sccz80/fa.asm' line 12: symbol 'init_floatpack' not defined
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

hmm seems for the last one I have to add -lm
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

The switch is an interesting one, however it looks like neither sdcc nor sccz80 accept a non-constant expression there, so basically you can't switch on variable - just use a #define or an enum instead, eg #define FX 0 - there's no need for the '=' which you've got in your snippet.

It looks like I removed delay() a while back and replaced it with the more meaningfully named msleep(int mills) - sorry about that, you should have had a compiler diagnostic about it though.
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

Cheers
bushy555
Member
Posts: 13
Joined: Tue Jul 16, 2013 9:31 am

Post by bushy555 »

Dom, That's awesome about the colours in putsprite ! Well done & thankyou.
Will have a play after I download a nightly build.
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

How can I recompile a Z88dk callee .asm file so it is incorporated in my compilation of my code?
The vz_score and vz_brick calls were changed from what I wrote in 2000 and are now not working so I need to fix it for my new game.
I've updated vz_score_callee.asm but when I build it's still wrong.
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

If you update in place you need to to the following steps (from libsrc):

rm vz_clib.lib
make vz_clib.lib
cp vz_clib.lib ../lib/clibs/
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

Thanks
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

Trying to work out how to pass values back from Z80 Assembly to my C code. I can't find any info on the z88dk wiki pages. I want to read the joystick values and give them back to C to work on. Any ideas?
Timmy
Member
Posts: 135
Joined: Sat Mar 10, 2012 4:18 pm

Post by Timmy »

Do you need special calls or just an input from a port?

If it's the latter, try this other recent thread: https://www.z88dk.org/forum/viewtopic.php?id=11168
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

There's a page on calling conventions here: https://github.com/z88dk/z88dk/wiki/CallingConventions - the return value goes in hl for an 8/16 bit value.

So I'm guessing your function should look something like this:

Code: Select all

; uint8_t read_joystick()

read_joystick:
_read_joystick:
    in  a,($20)
    ; Shuffle bits around if necessary to match a convention
    ld  l,a
    ld  h,0
    ret
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

So in C I'd use:
direction = read_joystick();
and it'd return that value?
User avatar
dom
Well known member
Posts: 1194
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Now I've looked at the spec, I'd probably do it something like this:

Code: Select all

#define UP 1
#define DOWN 2
#define LEFT 4
#define RIGHT 8
#define FIRE 16

extern uint8_t vz_joystick(int stick_number) __z88dk_fastcall;

...
int j = vz_joystick(1);

if ( j & UP ) {
...
} else if ( j & DOWN ) {
...
}

...
SECTION code_clib
PUBLIC vz_joystick
PUBLIC _vz_joystick

; uint8_t vz_joystick(int number) __z88dk_fastcall;

vz_joystick:
_vz_joystick:
    in   a,($2e)  ; Read joystick 1
    dec l            ; l = 1 is joystick 1, l = 2 is joystick 2
    jr  z,joystick_read 
    ; Read joy2
    in a,($2b)
joystick_read:
    cpl
    and @00011111
    ld l,a
    ld h,0
    ret
It's probably worth adding to the library to be honest - which emulator actually emulates the joystick?
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

I have a feeling MESS might do it but I'd have to check. VZEm definitely doesn't.
WauloK
Member
Posts: 63
Joined: Thu Oct 10, 2019 10:45 am

Post by WauloK »

I tested it on my Real VZ300. Up, Down, Left, Right work on both joysticks but not FIRE or the ARM button (fire2).

Whenever I copy a .vz file made with z88dk to my SD Card I get a notice:
The file filename.vz has properties that can't be copied to the new location.
Are you sure you want to copy this file without its properties?
I'm also testing an Arcade Game Designer as I assist a developer port it to support VZ computers. The VZ files made with that (which uses sjasm) does not have this properties dialog box in Windows.
Post Reply