Enterprise Forever

:UK => Enterprise DevCompo => Enterprise DevCompo #1 => Topic started by: geco on 2015.November.16. 20:40:05

Title: Q&A
Post by: geco on 2015.November.16. 20:40:05
Here you can ask help, and info about programming on Enterprise. :)

Enterprise DevCompo #1 (http://enterpress.news.hu/ep_devcompo_en.html)
Title: Re: Q&A
Post by: ssr86 on 2015.November.22. 11:32:05
I have some music composed with ArkosTracker for the ay. How can I use it in an Enterprise production? What are the limitations? Should I use a specific tracker for composing to be able to use it?
Title: Re: Q&A
Post by: geco on 2015.November.22. 12:54:29
I have some music composed with ArkosTracker for the ay. How can I use it in an Enterprise production? What are the limitations? Should I use a specific tracker for composing to be able to use it?
There is one simpler way, use the CPC Arkos Tracker player code, and insert IstvánV's AY emulation routine, the other convert the data to be playable on EP.
The limitations of the 1st solution:
if there are noise and tone in the same channel it can not be emulated on EP, so you have the choice what would you like to hear, noise or tone, or noise at tone frequency
if the music uses high frequency envelopes then the envelope emulation should be done in 1KHz interrupt, which takes some additional CPU, and if the frequency of envelope is higher then it will be cut , normally the CPU speed does not take too much, I used it in Star Sabre, and it is not slower than on CPC.
If you have the song (binary with player), I can convert one to you, and I can check if it can be automated.
Title: Re: Q&A
Post by: g0blinish on 2015.November.24. 12:07:08
How to define character set? I found memory map, character set is placed at $b480.

I use set character ... but i don't see values in debugger.
Title: Re: Q&A
Post by: Zozosoft on 2015.November.24. 12:38:42
I found memory map, character set is placed at $b480.
It is true when System Segment (FFh) paged to Z80 Page 2, and using EXOS version 2.1+
(At EP64 with EXOS 2.0 at B680h-...)

Character set structure: the 0-31 characters are for the ASCII codes 128-159.
Then in character memory stored in this order 128-159,32-127.
Each character 8x9 pixels. Firstly stored first line of each characters then the second line of each.

For example look for the SPACE: ASCII 32, then add 20h for the base address for the first byte, then add 80h for the next bytes:
B480h+20h=B4A0h the first byte
B4A0h+80h=B520h the second
etc
Title: Re: Q&A
Post by: g0blinish on 2015.November.24. 14:48:04
ok, thank you.
please explain adressing textmode:

if i understand description:
http://ep.homeserver.hu/Dokumentacio/Konyvek/EXOS_2.1_technikal_information/hardware/Nick.html

40 byte for text, 16 bytes for Line Parameter Table
40 bytes for text...

is it right?
Title: Re: Q&A
Post by: Zozosoft on 2015.November.24. 15:18:18
40 byte for text, 16 bytes for Line Parameter Table
40 bytes for text...
No.

LPT table continuous, each LPB are 16 bytes.
Text area usually continuous, and it is another memory area.

Each LPB have a own address pointer for the data memory.
These can be placed usually continuously in the memory, but also can be placed anywhere.

And the 40 bytes also not fixed. With the margins in the LPB you can choose the screen width.

And also possible to use different character sets in LPBs. For example one used for graphics elements in the game area, and another used for score board.

One important note: addresses in the LPT are video addresses, when accessing anything need to calculate the current Z80 address depending the used paging configuration.
Title: Re: Q&A
Post by: lgb on 2015.November.24. 16:10:12
Guys, I am not sure how useful it is, but I've just made a "quick" summary writing about the EP system (I think it can be useful for newcomers to the realm of Enterprise stuffs):

http://ep.lgb.hu/epdesc.txt

It does not have deep details (eg the exact bits byte meanings in LPB etc), just to try to help for getting the "big picture" about the Enterprise. It's unfinished (audio should be the next) and since I typed right now, it's surely overcrowded by typing mistakes (also, since my not-so-perfect English ...).

I guess Zozo should judge that it's correct at least from the view point of technical information on Enterprise :) Of course there are much better and more detailed information on Enterprise available, however I am not sure there is a "summary" style writing like mine, that can help to describe the whole stuff. Still, of course, reading of the detailed documentations _IS_ needed then!

If it's not so much usable, than just forget it :)
Title: Re: Q&A
Post by: Zozosoft on 2015.November.24. 16:38:50
Guys, I am not sure how useful it is, but I've just made a "quick" summary writing about the EP system
Great!
Title: Re: Q&A
Post by: endi on 2015.November.24. 16:40:17
cool
tip: put this, and other links in the first post
we can collect some useful links in the first post
Title: Re: Q&A
Post by: lgb on 2015.November.24. 17:19:05
I guess, it would be better to put it into the wiki, it's easy to place links then, and edit/modify/fix the content as well. Now I tried to extend the text a bit, however I am the lamest with the audio I am afraid ... I would not make it much more longer, as it should be a summary stuff, detailed description on given hw/sw elements should be read about then somewhere else :)
Title: Re: Q&A
Post by: pear on 2015.November.24. 17:25:36
To edit the Wiki need to have some additional rights, whether I need to register separately ?
Title: Re: Q&A
Post by: g0blinish on 2015.November.24. 18:05:09
better is examples in wiki articles. LPT is tough cookie like DL for Atari..
Title: Re: Q&A
Post by: ssr86 on 2015.November.24. 18:15:25
Here's a "quick" working example for charmode...
It shows the atari 8bit font (8x8) in char128+2color mode (notice that pixels are wide as in LPIXEL 2color mode).
There are more files but what should interest you is the lpt.asm file where the lpt is produced. One modeline per character line (here each represents 8 screen lines). Fonts.asm has the font data (stored like in the atari_font.png - simple conversion). The loade.asm has some code that assigns the segment numbers for exos compatibility - I need to modify the gfx addressses in the lpt to match the assigned segments... (there is also some unused code for loading data from file...)

First I store the fontdata and charmap addresses with base 0 in the lpt but when I know the assigned segment number then I add that segment base to each address in the lpt ($FC = base $0000, $FD = base $4000 etc.). In each char modeline the fondata address stays the same but the charmap needs to be updated for each modeline (adding the number of chars per display line - here 40, because I use a standard 320 pixels wide screen setup, but If you change the margins then you can have more (or less)).

Sorry if the code isn't very clear... However I hoope that it at least shows what you wanted...
Title: Re: Q&A
Post by: ssr86 on 2015.November.24. 18:40:05
cool
tip: put this, and other links in the first post
we can collect some useful links in the first post
Yeah, and as it's an "all in one" topic, then a "table of contents" with links to the posts where a new question popped up could make it easier to browse and search through.
Title: Re: Q&A
Post by: lgb on 2015.November.24. 22:54:50
To edit the Wiki need to have some additional rights, whether I need to register separately ?

That's a good question, I have no idea :) Often it would be useful to store information there. By its nature, the forum is a the good place to discuss things etc, but it would be cool to put the final result of such a discussions on the wiki (maybe with links to the discussion posts) as it's almost impossible to find code parts etc were discussed throughout the forums after some months/years and trying to put them together ...
Title: Re: Q&A
Post by: g0blinish on 2015.November.25. 05:25:04
I took sample.asm and try to write characters to VRam. Nothing appears. What is a mistake?
Title: Re: Q&A
Post by: ergoGnomik on 2015.November.25. 07:08:55
I took sample.asm and try to write characters to VRam. Nothing appears. What is a mistake?
Mistake:
:ds_icon_cheesygrin:

Sorry, I couldn't resist. Anyway, this is my wild guess, but you seem to expect characters on a graphic screen. I don't know Z80 assembly very well, meaning almost not at all, but go to the end of prj.asm and read carefully the explanations of the byte constants right after the LPT label.
Title: Re: Q&A
Post by: Zozosoft on 2015.November.25. 07:12:21
What is a mistake?
In my sample.asm pixel graphics screen (320*200, 4 colors) definied at Z80 address C000h-
You write data at 4000-40FFh, then nothing changed on the screen.

Another little problem: your code not at ";there is the room for the main program", then it is done before the screen setting sent out the Nick.
If you use the JP $, then also don't see anything if you use the right C000h start address.
Title: Re: Q&A
Post by: Zozosoft on 2015.November.25. 07:14:46
but you seem to expect characters on a graphic screen.
This is the third problem :-)

If g0blinish want I can modify the sample.asm for a character screen.
Title: Re: Q&A
Post by: g0blinish on 2015.November.25. 07:19:51
ZoZoSoft, thank you, now it works:

I must teach LPTs..
Title: Re: Q&A
Post by: g0blinish on 2015.November.25. 08:00:36
So, if I understand, where are mo textmode with user-defined charset ?
Title: Re: Q&A
Post by: ssr86 on 2015.November.25. 08:51:08
So, if I understand, where are mo textmode with user-defined charset ?
The example I've posted used 2-color char128 mode with a user-defined font (atari font). :oops:

Ep has 4 (?) types of video modes:
- PIXEL - similar to amstrad cpc modes (the memory layout is different)
- LPIXEL - like pixel but with wider pixels (twice as wide, so 4-color pixels are wide like in 16-color pixel mode)
- CHAR - where you have a font and character map; the 3 modes differ in the number of characters (so memory) they use for the font (64, 128 and 256 characters in font); pixels are wide like in lpixel modes
- ATTRIBUTE - similar to zx spectrum (?) used to emulate the speccy screen (?); you have 2-color graphics + attribute map

Note: in PIXEL and LPIXEL, using VRES (makes one screen line to repeat for all display lines for the given modeline) with some bigger lpt you can get a screen with taller pixels (pixels can be 1-256 lines high - should be useful for many effects; for example one could do vertical rasters with just one line of screen data and make nick repeat that line for the whole screen). These could give you a gameboy/atari lynx resolution screen. You could also have a 80x64 resolution in 256 colors.
Title: Re: Q&A
Post by: geco on 2015.November.25. 09:04:27
- ATTRIBUTE - similar to zx spectrum (?) used to emulate the speccy screen (?); you have 2-color graphics + attribute map
Similar, but different :) You can set paper and ink colors for every 8x1 pixel instead of Speccy 8x8 pixel.
Speccy screen can be built up by Line Parameter definition for each pixel line, and attribute address of every 8 line parameter definition points to the same position in video RAM :) , and other difference is the ink and paper colour setting is different, on EP bit7-4 paper color, and bit3-0 is ink color.
Title: Re: Q&A
Post by: g0blinish on 2015.November.25. 09:14:54
ouch! i missed post with sources. now trying to compile with sjasm+

Added fixed source for 1.07 RC1
Title: Re: Q&A
Post by: geco on 2015.November.25. 10:34:07
ouch! i missed post with sources. now trying to compile with sjasm+
As I see the font address is not correct, the Nick address of font has to be divided by the charmod character numbers, if you use CHR256 then the Nick address of font has to divide by 100h, if you use CHR64 then it has to be divided by 40h and so on, and this address has to be filled into LPT.
Title: Re: Q&A
Post by: ssr86 on 2015.November.25. 10:49:09
As I see the font address is not correct, the Nick address of font has to be divided by the charmod character numbers, if you use CHR256 then the Nick address of font has to divide by 100h, if you use CHR64 then it has to be divided by 40h and so on, and this address has to be filled into LPT.
Uh, I messed that up... :oops:
However in my example the font address is at $0000 in the video segment so the bug hasn't been visible...
Title: Re: Q&A
Post by: g0blinish on 2015.November.25. 13:34:45
any example of ATTRIBUTE? I stuck with modes ):
Title: Re: Q&A
Post by: geco on 2015.November.25. 13:49:48
any example of ATTRIBUTE? I stuck with modes ):
Here is a Spectrum Attribute mode definition, extra colours have been used
Title: Re: Q&A
Post by: geco on 2015.November.25. 14:12:28
Here is a Spectrum Attribute mode definition, extra colours have been used
You can use the same method for define a normal attribute mode , where 1 attribute byte stands for 8x1 pixel, just have to increase attribute video memory address for each line, or you can define it with one line and give the Nick address of Attribute in byte 4-5 and give the nick address of bitmap in byte 6-7 in the line, and just change the 0th byte to 100h-screen height value ( in pixel rows )
In this setup the Attribute data will be continuous from the specified address, and this is true for bitmap data also.
Title: Re: Q&A
Post by: g0blinish on 2015.November.25. 14:55:33
Yet another example. Something wrong with colors(bright?)
Title: Re: Q&A
Post by: Zozosoft on 2015.November.25. 15:49:29
Yet another example. Something wrong with colors(bright?)
Using Spectrum screen need to convert attribute bytes.

Spectrum have a 1 bit flash, 1 bit bright, 3 bit paper, 3 bit ink
Enterprise: 4 bit paper, 4 bit ink

Another problem the color order:
Spectrum: black, blue, pink, green, cyan, yellow, white
On Enterprise: black, red, green, yellow, blue, pink, cyan, white. This is fixed because the FIXBIAS used for the 8-15 colors.

Another problem come, with the "bright black": if bright colors used as BIAS, then the brigh balck will be brown.
Solution 1: use BIAS=0 then, bright black is also black. Then the 8-15 colours are the dark, and 0-7 (which are free definiable) are the bright colours.
Solution 2: use bright BIAS, and handle at the conversion the "bright black" converted as color 0. Then the 0-7 colors are the drak, and 8-15 colors are the bright colors.

EP colors (http://ep.lgb.hu/colors.html)
Title: Re: Q&A
Post by: g0blinish on 2015.November.25. 16:08:41
I think I got what i want. Maybe game looks lame, but it is a game;)
Title: Re: Q&A
Post by: Zozosoft on 2015.November.25. 16:08:54
This is my Spectrum screen converter. It is use built in attribute and colors table, but these can be replaced by ATTRIB and COLORS file (binary).
Title: Re: Q&A
Post by: g0blinish on 2015.November.26. 07:54:17
Little question about example I attached:

here is LPT:

LINE        db 255,14H,15,2FH,0,0,0,0

and colors:
            db 0,32,72,104,144,176,216,248

32 - is blue
72 - is red
44 - is green

is it right?

Title: Re: Q&A
Post by: geco on 2015.November.26. 08:53:11
32 - is blue
72 - is red
44 - is green

is it right?
the 1st 2 is yes :) 44 is dark blue+medium red + light blue

bit setting of EP colors are
GRBGRBGR
b7------b0
Title: Re: Q&A
Post by: Zozosoft on 2015.November.26. 09:40:08
Look the EP colors page (http://ep.lgb.hu/colors.html) what I linked previously :-)
Title: Re: Q&A
Post by: g0blinish on 2015.November.26. 09:42:17
Look the EP colors page (http://ep.lgb.hu/colors.html) what I linked previously :-)

tes, thank you, I found bright color xD
Title: Re: Q&A
Post by: g0blinish on 2015.November.26. 17:01:08
wher to read about FIXBIAS and BIAS?
Title: Re: Q&A
Post by: geco on 2015.November.26. 18:10:29
Here you can read about it in chapter 13 (http://ep.homeserver.hu/Dokumentacio/Konyvek/EXOS_2.1_technikal_information/hardware/Nick.html)
and there is the colour table what Zozo attached , 8 colors are attached for every bias value (bit0-bit5 you can set BIAS values, this is 32 values)
The colors are attached by bias value are : bias value * 8 this is the start position, and the next 7 colours belonging to it.
Bias    EP color
00h      00-07h
01h      08-0fh
02h      10-18h
.
.
.
31h      f8-ffh
Title: Re: Q&A
Post by: Zozosoft on 2015.November.26. 18:29:57
But better way to use EXOS BIAS variable instead the direct port write.
Code: ZiLOG Z80 Assembler
  1.                 LD BC,100H+28   ;B=1 write
  2.                                 ;C=28 number of system variable (BORDER)       
  3.                 LD D,x          ;new value
  4.                 EXOS 16         ;handling EXOS variable

In this way you can use the standard color code (top 5 bit used).
And port 80h also control the internal speaker. For the right way need to get the current state from the SPEAKER variable and put to bit7.
Title: Re: Q&A
Post by: g0blinish on 2015.November.27. 07:16:20
how to enable breakpoints at debugger?

as I understand
F8:0100x

"syntax error" (
Title: Re: Q&A
Post by: Zozosoft on 2015.November.27. 08:22:52
You wrote the "x" with small letter?
Title: Re: Q&A
Post by: g0blinish on 2015.November.27. 09:30:22
yes.
Title: Re: Q&A
Post by: Zozosoft on 2015.November.27. 09:35:14
It is working for me.
Title: Re: Q&A
Post by: g0blinish on 2015.November.27. 09:39:44
nope(
Title: Re: Q&A
Post by: Zozosoft on 2015.November.27. 09:46:12
The right solution:
[attach=1]
Title: Re: Q&A
Post by: g0blinish on 2015.November.27. 09:51:26
same as my screenshot, emulator 2.0.9.1
Title: Re: Q&A
Post by: Zozosoft on 2015.November.27. 10:01:43
same as my screenshot, emulator 2.0.9.1
No.
In your:
-crazy data in the breakpoint window
-something in the LUA script window
[attach=1]
Title: Re: Q&A
Post by: g0blinish on 2015.November.27. 10:06:15
aah, what sucks(

I convert to ZX and debug code into proper debugger )
Title: Re: Q&A
Post by: Zozosoft on 2015.November.27. 10:17:29
At the top left window can you enter commands (dump, modify, load, save memory, modify registers, IO ports), enter ? for help.
To the right window can you enter brekapoints.
Bottom window for the LUA scripts (for a advanced tasks).
Title: Re: Q&A
Post by: g0blinish on 2015.November.28. 17:53:41
How to scan keyboard?

I found map of ports here:
http://www.ep128.hu/Ep_Konyv/Converting_Spectrum_Programs.pdf

and how fire is defined in ep128emu? I mean what key is for fire?
Title: Re: Q&A
Post by: lgb on 2015.November.28. 18:20:20
How to scan keyboard?

I found map of ports here:
http://www.ep128.hu/Ep_Konyv/Converting_Spectrum_Programs.pdf

and how fire is defined in ep128emu? I mean what key is for fire?

Send the desired keyboard matrix row with writing port 0xB5, then you can read the status of that selected row on the same port, by reading port 0xB5. Well, I always confuse row/column :) but in the diagram you also mentioned, it's what you read for example. The internal joystick (named as "JOY" on the diagram) of EP are simply behaves as any other keys on the keyboard, no difference at all (technically keys and internal joystick pad points are the very same on the keyboard membrane only the physical design of buttons and internal joystick handle are different). You can see on the diagram too ("JOY" up/down/left/right among the "normal" keys in the matrix). However external joystick(s) are complete different issue (named as "JOY1" and "JOY2"), they are not the very same process as you would do with the keyboard+internal joystick, that involves port 0xB6 too. You can see this in the right column on the diagram (I mean the diagram/matrix on page 4 of that PDF).

Honestly I don't know how _external_ joystick(s) are emulated in ep128emu, including the fire button ...  I think you should choose "Keyboard map" in the "Options" menu, so you can define keys assigned to the EP keyboard and external joystick "events".
Title: Re: Q&A
Post by: gflorez on 2015.November.28. 18:26:28
For FIRE internal joystick the SPACE key is used.
Title: Re: Q&A
Post by: g0blinish on 2015.November.28. 18:58:20
I understand matrix, but i cannot find value for arrows.

Title: Re: Q&A
Post by: lgb on 2015.November.28. 19:17:50
I understand matrix, but i cannot find value for arrows.

What kind of "arrows" do you mean? For internal joystick directions of movements, it's "JOY UP" for internal joystick direction "up" (ie: row 7, bit position 3 named as "b3" in the matrix so it would be write value 7 to port 0xB5 to select row to scan, read port 0xB5 and if b3 - bit 3 - is _reset_ then internal joystick function "up" is activated/used), and so on.

Update: if you mean the "cursor arrow" keys (I'm sorry it just come into my mind that you meant maybe about the cursor arrow keys when you wrote "arrows"), on EP the internal joystick is used for that, there is no separated "joystick" and "cursor arrow keys", they are the very same entities (this means, that on EP you use the internal joystick for cursor movements as well even in BASIC etc - this can be "strange" for newcomers, I can imagine ...). Of course I meant the _internal_ joystick again (built in the EP), the _external_ joysticks are different issue.
Title: Re: Q&A
Post by: g0blinish on 2015.November.29. 05:25:01
lgb, thank you. I mean "cursor keys".
Title: Re: Q&A
Post by: g0blinish on 2015.November.29. 11:33:31
a game almost ready/ What next - contact orginizers or create thread here?
Title: Re: Q&A
Post by: lgb on 2015.November.29. 12:07:11
lgb, thank you. I mean "cursor keys".

It was my fault, that I couldn't get what you mean with "arrows" at first :)
Title: Re: Q&A
Post by: lgb on 2015.November.29. 12:15:36
a game almost ready/ What next - contact orginizers or create thread here?

Well, I am not an organizer, but I think, since one program is already posted (flapflap.bas by endi) you may want to post yours there too. Maybe someone then can create a new thread/topic and move the posts if they really want? But it is just a guess from me, I am only curious what the second entry will be and I'd like to see it as soon as possible :) :) :)
Title: Re: Q&A
Post by: g0blinish on 2015.November.29. 12:32:38
I think my questions ain't offtopic.  will wait geco's reply.
Title: Re: Q&A
Post by: lgb on 2015.November.29. 13:31:34
I think my questions ain't offtopic.  will wait geco's reply.

Of course it's not off-topic, since this very topic is for Q&A about the devcompo :)
Title: Re: Q&A
Post by: g0blinish on 2015.November.30. 08:48:51
if possible to switch segments via ports B0h-B3h, can I read values from these ports?
Title: Re: Q&A
Post by: Zozosoft on 2015.November.30. 08:58:20
can I read values from these ports?
Yes.
Title: Re: Q&A
Post by: g0blinish on 2015.November.30. 09:05:20
Back again to ZX Spectrum creation:

Code: [Select]
;11.23 Function 25 - Free Segment
;    Parameters :  C segment number
;    Results    :  A status
                              ;Az 0FAH szegmens felszabaditasa...
                              ; For the Liberation of 0FAH segment ...
            LD C,0FAH
            EXOS 25
                              ;... es belapozasa a 2-es lapra Ugyanez az 0FCH szegmenssel
                              ; ... And belapozasa the 2nd sheet of the same segment 0FCH
            LD A,0FAH
            OUT (0B2H),A ; segment FAh at $8000

            LD C,0FCH;;free segment FCh
            EXOS 25

            LD A,0FCH
            OUT (0B1H),A;segment FC at $4000

 So, segment FCh always related to Nick?
Title: Re: Q&A
Post by: lgb on 2015.November.30. 09:11:06
So, segment FCh always related to Nick?

Segments FC,FD,FE,FF are always (both on EP64 and EP128) the video RAM ("VRAM") which is used by the Nick linearly _regardless_ of the state of ports B0...B3 (these ports map segments for the CPU only, Nick always sees the VRAM - and only the VRAM - segments directly and linearly).
Title: Re: Q&A
Post by: Zozosoft on 2015.November.30. 09:13:33
So, segment FCh always related to Nick?
Yes.

But the exampled source code are wrong for memory allocation.
Title: Re: Q&A
Post by: g0blinish on 2015.November.30. 09:16:04
Yes.

But the exampled source code are wrong for memory allocation.

wrong in "get a free Video segment"?

Title: Re: Q&A
Post by: Zozosoft on 2015.November.30. 09:20:33
wrong in "get a free Video segment"?
Yes. EXOS 25 only can be used when you allocated the segment.
See my SAMPLE.ASM for right memory allocation. (https://enterpriseforever.com/other-topics/maybe-we-should-organize-a-gamedevcompo/msg50758/#msg50758)

And I will shortly upload my loader for Spectrum conversions.
Title: Re: Q&A
Post by: g0blinish on 2015.November.30. 09:23:51
And I will shortly upload my loader for Spectrum conversions.

Yes, great to see one!
Title: Re: Q&A
Post by: g0blinish on 2015.November.30. 09:48:37
Yes. EXOS 25 only can be used when you allocated the segment.
See my SAMPLE.ASM for right memory allocation. (https://enterpriseforever.com/other-topics/maybe-we-should-organize-a-gamedevcompo/msg50758/#msg50758)


for some reasons, routine jumps to the exit routine. How to detect error and reason?
Title: Re: Q&A
Post by: Zozosoft on 2015.November.30. 10:00:32
for some reasons, routine jumps to the exit routine. How to detect error and reason?
After any EXOS call NZ flag set if any error occured.
Then the A register contain the error code (http://enterprise.iko.hu/errors.htm), which can be used for advanced error handling.

If you want get the error message can be asked from the system with EXOS 28 call. (http://gafz.enterpriseforever.com/Dokumentacio/Konyvek/EXOS_2.1_technikal_information/exos/kernel/Ch11.html#11.26)
Title: Re: Q&A
Post by: g0blinish on 2015.November.30. 10:11:04
252 "Stack overflow". very interesting.
Title: Re: Q&A
Post by: BruceTanner on 2015.November.30. 10:20:33
252 "Stack overflow". very interesting.
252 = FC in hex. Looks to me like segment number and error code might have got mixed up! :oops:
Title: Re: Q&A
Post by: Zozosoft on 2015.November.30. 10:24:41
252 "Stack overflow". very interesting.
EXOS have a own stack in the System Segment. And EXOS calls can be use another EXOS function calls. Then need always check the available space in the System Stack. Simple example: BASIC use Read Block function to read EDITOR channel, for read the new line entered by the user.
The EDITOR device read characters from the KEYBOARD device, and write characters to the VIDEO device. These are also additional EXOS calls.
And when the user press the Enter then return the EDITOR from the main EXOS call to the BASIC.
Title: Re: Q&A
Post by: Zozosoft on 2015.November.30. 13:22:49
Yes, great to see one!
There is it.
It is make a standard 48K Spectrum memory map. Allocate memory on proper way, and can exit back to the EXOS.
Also can allocate 48K memory when only 32K available :-) Do a trick: combine the Zero Page and System segments for free up the Zero Page Segment for additional 16K memory. It is reversed on Exit, then no any system data damaged.

It is load two files, one screen files, and one program file which contain the main program.
Also support compressed mode with Epcompress from IstvanV.
Title: Re: Q&A
Post by: g0blinish on 2015.November.30. 13:26:06
how good is ecompress?
Exomizer and zx7 gives good compress ratio.(zx7 for ZX screens)
Title: Re: Q&A
Post by: Zozosoft on 2015.November.30. 13:42:10
how good is ecompress?
Some examples:
Spindizzy SCR 6912 -> 912, PRG 34112 -> 23437
New Zealand Story SCR 6912 -> 3106, PRG 41036 -> 20612, music 5120 -> 3534
Heartland SCR 6912 -> 3295, PRG 33432 -> 22190

It is with the -m3 mode of the Epcompress. It is have many another options. I used this because good compromise with the size and decompress speed.
Title: Re: Q&A
Post by: IstvanV on 2015.November.30. 15:10:28
epcompress -m2 is a similar format to Exomizer, with some tweaks.
epcompress -m3 has a few percents worse compression ratio, but the decompressor is simple, fast, and only requires a small amount of memory (it does not use any tables)
epcompress -m0 is the most complex format, it may compress better than the -m2 mode, but it is not worth it most of the time because of the large and slow decompressor

epcompress allows for creating .com files that uncompress to greater than 47.75 KB size, as long as the compressed version of the program does not exceed that limit. With the -m3 method, it is possible to use all memory from 100H to FFFFH, the others reduce the upper limit because of the extra space required by the decompressor code and data.

'dtf (https://enterpriseforever.com/programozas/fajltomorites-enterprise-on/msg31929/#msg31929)' can also be used for creating packed files that are easy to load with RST 28H calls (these work similarly to EXOS 6, except the channel number is always 1, and the block size is determined at compression, so BC is ignored). It supports the same algorithms as epcompress, use '-lz' for the -m3 method, and '-lz2 -9' for -m2.

With 'dtf', the pack file is already opened on channel 1 when the original loader is started, and each compressed data block can be read with RST 28H (DE is the start address). The decompressor code uses the area under 100H.

dtf -cp -lz PACKFILE LOADER.COM DATA1 DATA2 ...
dtf -cl -lz LOADER2.COM PACKFILE

These commands pack a program and its data using the simplest and fastest algorithm, and create a new loader for the packed file.
Title: Re: Q&A
Post by: IstvanV on 2015.December.01. 11:37:24
Here is a comparison of the compression ratios with a few files (all available at ep128.hu):
[attachimg=1]
All files have been compressed in "raw" mode as a single data block (decompressor code is not included).
Title: Re: Q&A
Post by: g0blinish on 2015.December.01. 12:36:43
some guys said what HRUST is better, but i didn't test.
Title: Re: Q&A
Post by: IstvanV on 2015.December.03. 08:05:37
These file sizes are with "mhmt -hst", using this program (https://code.google.com/p/mhmt/) for the compression (not sure if there is a better version):

ARIZONA.RAW - 44706
BATMAN.APL - 30368
BATMAN.COM - 3480
EXOLON.PRG - 21684
EXOLON.SCR - 2236
Title: Re: Q&A
Post by: g0blinish on 2015.December.03. 08:29:48
These file sizes are with "mhmt -hst", using this program (https://code.google.com/p/mhmt/) for the compression (not sure if there is a better version):

ARIZONA.RAW - 44706
BATMAN.APL - 30368
BATMAN.COM - 3480
EXOLON.PRG - 21684
EXOLON.SCR - 2236

mhm- lamers;) mhmt works unstable.
Title: Re: Q&A
Post by: g0blinish on 2015.December.06. 12:29:40
how to compile pt3 player?

LD HL,SPCCOMS+#FF20-#2000
sjasm says "Bytes lost".
Title: Re: Q&A
Post by: geco on 2015.December.06. 12:33:06
how to compile pt3 player?

LD HL,SPCCOMS+#FF20-#2000
sjasm says "Bytes lost".
I think you can ignore this error message, the byte lost means in this case 01xxxx, 01 is lost, but you can try with other order it may work:
LD HL,SPCCOMS-#2000+#FF20
or just
LD HL,SPCCOMS+#DF20
Title: Re: Q&A
Post by: g0blinish on 2015.December.06. 12:34:38
well, pt3play works with tune, but code from player - not.
Title: Re: Q&A
Post by: geco on 2015.December.06. 12:37:20
please attach the binary, and the source, i would check it.
Title: Re: Q&A
Post by: Zozosoft on 2015.December.06. 12:49:56
how to compile pt3 player?

LD HL,SPCCOMS+#FF20-#2000
sjasm says "Bytes lost".
With Sjasm 0.39 no problem.
Title: Re: Q&A
Post by: g0blinish on 2015.December.06. 12:54:14
oh, yes. my mistake:

missed it:
Code: [Select]
LD A,30H
OUT (0B4H),A

thank you for help.
Title: Re: Q&A
Post by: geco on 2015.December.06. 13:00:10
Yw, if you have any problem, please attach the bin and the source , we can check it.
Title: Re: Q&A
Post by: g0blinish on 2015.December.06. 13:01:21
OK, but i don't want to spoil a game.

Title: Re: Q&A
Post by: g0blinish on 2015.December.06. 14:00:21
How to check if any key pressed?

for example, on ZX is
Code: [Select]
xor a
in a,($FE)
Title: Re: Q&A
Post by: geco on 2015.December.06. 14:11:05
How to check if any key pressed?

for example, on ZX is
Code: [Select]
xor a
in a,($FE)
You have to read all key rows, something like the following:
Code: [Select]
chkkey
   ld b,0ah
readkey
   ld a,b
   dec a
   out (0b5h),a
   in a,(0b5h)
   inc a
   ret nz          ;NZ if key pressed
   djnz readkey
   ret            ; Z if key not pressed
Title: Re: Q&A
Post by: geco on 2015.December.06. 14:18:35
if you want to check joystick also then:
Code: [Select]
chkkey
   ld b,0ah
readkey
   ld a,b
   dec a
   out (0b5h),a
   in a,(0b5h)
   ld c,a
   in a,(0b6h)
   or 0feh
   and c
   inc a
   ret nz          ;NZ if key pressed
   djnz readkey
   ret            ; Z if key not pressed
Title: Re: Q&A
Post by: g0blinish on 2015.December.06. 15:05:55
I made simple utility LPT helper. maybe one help.
type number with $ as hex, % as binary.
Title: Re: Q&A
Post by: gflorez on 2015.December.06. 17:49:41
if you want to check joystick also then:
Code: [Select]
chkkey
   ld b,0ah
readkey
   ld a,b
   dec a
   out (0b5h),a
   in a,(0b5h)
   ld c,a
   in a,(0b6h)
   or 0feh ;11111110b
   and c
   inc a
   ret nz          ;NZ if key pressed
   djnz readkey
   ret            ; Z if key not pressed

With new Entermice: to test the three fire buttons put "or 0f8h"("11111000b") instead of  "or 0feh"("11111110b")  on rows 0 and 5 of external joysticks(port 0b6h).
Title: Re: Q&A
Post by: g0blinish on 2015.December.13. 19:40:42
Does anybode tried to build LPT for Timex multicolor mode?
Title: Re: Q&A
Post by: Zozosoft on 2015.December.13. 19:50:51
Does anybode tried to build LPT for Timex multicolor mode?
If I understood right then I think it is easy.
Every screen byte have the attribute byte at +2000h address?
Title: Re: Q&A
Post by: g0blinish on 2015.December.13. 21:05:09
yes,
$4000-$6000.
Title: Re: Q&A
Post by: Zozosoft on 2015.December.13. 21:59:17
Can you upload some sample images? Then I will modify my Spectrum loader for this mode.
Title: Re: Q&A
Post by: g0blinish on 2015.December.14. 06:34:52
Can you upload some sample images? Then I will modify my Spectrum loader for this mode.

this is simple conversion
Title: Re: Q&A
Post by: g0blinish on 2015.December.14. 07:48:14
And one question: is possible to change LPT's parameter every frame?
Title: Re: Q&A
Post by: geco on 2015.December.14. 08:27:41
And one question: is possible to change LPT's parameter every frame?
Yes, any parameter can be changed, or if you need speed, then you can build more LPT's and change between them in every frame.
Title: Re: Q&A
Post by: IstvanV on 2015.December.14. 10:51:19
It is even possible (although not very useful) to change the current LPB every line (with the exception of the number of lines, LD2, and in VRES=1 mode, LD1), but not during a line because it is only read once at the beginning of the line. The border color and bias (https://enterpriseforever.com/programming/has-nick-got-any-useful-bugs/msg51503/#msg51503) can be changed at any time.
Title: Re: Q&A
Post by: Zozosoft on 2015.December.14. 16:47:42
this is simple conversion
It is right results, or something wrong? :oops:
[attach=1]
Title: Re: Q&A
Post by: g0blinish on 2015.December.14. 16:55:15
I used bmp2scr:
Title: Re: Q&A
Post by: Zozosoft on 2015.December.14. 17:07:26
Ok, fixed now. .MLT file structure little strange :oops:
[attach=1]
Title: Re: Q&A
Post by: geco on 2015.December.14. 18:40:33
Do you plan to use the speccy format screen? Because with EPIMGCONV the screen conversion would be better.
Title: Re: Q&A
Post by: IstvanV on 2015.December.14. 18:55:35
It should look best in 16-color PIXEL mode, but it may need manual selection of palette colors and bias.
Title: Re: Q&A
Post by: geco on 2015.December.14. 19:04:42
I made 2 conversion in PIXEL mode 16 colours:

1 LPT line (LPB) definition for the whole picture (file 11 executable)
epimgconv -mode 2 -size 42 240 -dither 0 0 -nointerp 1 -palres 0 -gamma 1.1 atari000.png 11
[attach=1]

1 LPB for each line (file 12 executable)
epimgconv -mode 2 -size 42 240 -dither 0 0 -nointerp 1 -palres 1 -gamma 1.2 atari000.png 12
[attach=2]
Title: Re: Q&A
Post by: IstvanV on 2015.December.14. 19:51:01
Here are a few attempts at making the palette of the image EP compatible (it could probably be improved by changing some colors):
[attachurl=1]
[attachurl=2]
[attachurl=3]

With -palres 1, these can be converted without loss to EP format (there are 20 colors on the image, so -palres 0 is always lossy):
epimgconv_sse2 -mode 2 -quality 9 -size 42 240 -palres 1 -nointerp 1 -dither 0 0 -border 248 -outfmt 11 atari001.png atari001.pic
epimgconv_sse2 -mode 2 -quality 9 -size 42 240 -palres 1 -nointerp 1 -dither 0 0 -border 248 -outfmt 11 atari002.png atari002.pic
epimgconv_sse2 -mode 2 -quality 9 -size 42 240 -palres 1 -nointerp 1 -dither 0 0 -border 56 -outfmt 11 atari003.png atari003.pic
Title: Re: Q&A
Post by: g0blinish on 2015.December.19. 11:48:06
I am looking at sources: Nickdemo etc..

why neccessary to make:
Code: [Select]
CALL VID ;get a free Video segment

instead of
Code: [Select]
            LD      A,RAM2         ; PUT VIDEO RAM IN PAGES 2 AND 3
            OUT     (PAGE2),A      ; (PAGE 1 NOT USED, PAGE 0 ALREADY
            INC     A              ;  HAS THIS CODE IN)
            OUT     (PAGE3),A

is it comptibility feature or not?
Title: Re: Q&A
Post by: Zozosoft on 2015.December.19. 12:30:57
Iis it comptibility feature or not?
Yes. The solution what you see in my examples are 100% EXOS compatible, will run on all Enterprise configuration, or exit if not enought memory available, without overwrite anything in the system memory.
Many old programs which using fixed memory addresses make a lot of compatibility problems. For example run only tape system, not with floppy (these are fixed at many years ago), at current times not run from HDD or SD card.
Another problem when the program don't run on EP64, even if it is have a memory expansion. Also exist some incompatible programs which don't run if you have more than 128k memory.
We continously fixing the old prorams, and new ones writed in 100% compatible mode.

I think will be good if the new EP programers start on the right way :-)
Just need to copy-paste from my examples :-)

It is allocate all memory from the EXOS. Calculate the video addresses from the segment number of the allocated video memory.
For the paging use variables for the segment numbers, at the paging just need to use LD A,(P2S) instead use LD A,xx
Title: Re: Q&A
Post by: IstvanV on 2015.December.19. 17:44:06
If the program requires 3 full video segments (48K), then it is somewhat easier, because the segments will always be FC-FEh. So, it is possible to use fixed video addresses. But the segments should still be allocated with EXOS 24. :)
Title: Re: Q&A
Post by: SlashNet on 2015.December.28. 13:19:35
Now I writing small game on basic.

But when the code has grown to a certain size, ZZZIP compiler give me error "Too many labels". I understand that the error occurs because of a number of factors (the number of variables, the amount of code and transitions).

I tried to use the program ZZZIPSRC + IDEA, but IDEA give me another error. (see shots) I tried to increase amount of memory in configuration, but nothing changed. :(
(i forgot to clear font. just ignore non standard characters)
[attach=1]

Is there a solution to this problem?:smt022
Title: Re: Q&A
Post by: ssr86 on 2015.December.28. 16:47:38
I have a question regarding the timing difference between vmem access and "normal" memory access.

I have run ldir with bc=2048 and got the following results:

Code: [Select]
+-----+-----+-----+-----+
| HL  | DE  |wait |lines|
+-----+-----+-----+-----+
| Vm  | Vm  | on  | ~192|
| Vm  | Nm  | on  | ~156|
| Nm  | Vm  | on  | ~156|
| Nm  | Nm  | on  | ~144|
+-----+-----+-----+-----+
| Vm  | Vm  | off | ~192|
| Vm  | Nm  | off | ~192|
| Nm  | Vm  | off | ~192|
| Nm  | Nm  | off | ~160|
+-----+-----+-----+-----+

Taking that into account, would it make sense for you to store some buffers used in drawing routines inside video memory?
I'm asking for opinions because I know it depends on "memory vs speed" issues and really depends on the game...
I'm considering trying out triple buffering for a single screen game but struggle to find some place in the common segment (f8) for the clean buffer. I couls place it in the video memory alongside the other buffers which would simplify the access to it but would also slow down the routines from what I can see from the table...

When and why would you want to enable the wait states on dave port $bf?
Title: Re: Q&A
Post by: endi on 2015.December.28. 17:06:47
Now I writing small game on basic.

small basic program with too many labels? :)
Title: Re: Q&A
Post by: IstvanV on 2015.December.28. 17:18:20
When and why would you want to enable the wait states on dave port $bf?

Enabling the wait states is generally only useful if you need:
- compatibility with real machines that use unusually slow DRAM; I think these are a small minority, but Zozosoft could probably tell more about how much of an issue this is in practice
- slower speed for better compatibility e.g. with the timing of ZX Spectrum conversions; writing 4 to port BFh results in comparable performance to a 3.5 MHz Z80 with no wait states

Otherwise, it is better to disable wait states by writing 0Ch to port BFh.
Title: Re: Q&A
Post by: Zozosoft on 2015.December.28. 17:33:54
- compatibility with real machines that use unusually slow DRAM; I think these are a small minority, but Zozosoft could probably tell more about how much of an issue this is in practice
Only very few machines got a slow DRAM or EPROM chips, which need the wait state. Because many programs use the no wait setting, then these machines failed and went to repair at about 25-30 years ago :-) Personally I replaced memory in one machine, and about 2-3 German Basic EPROM.
At the early 90's some system expansions started set the no wait as default at the startup.
Finally I decided to change the default in my memory test.
Title: Re: Q&A
Post by: SlashNet on 2015.December.28. 17:36:24
small basic program with too many labels? :)
No. I wrote: "small game on basic" ;)
Title: Re: Q&A
Post by: g0blinish on 2016.January.07. 05:37:18
I took source from Col256 demo:
http://www.ep128.hu/Ep_Demo/Demo_eng.htm

seems code is out of synchronization.
how to fix one?
Title: Re: Q&A
Post by: geco on 2016.January.07. 09:00:49
I took source from Col256 demo:
http://www.ep128.hu/Ep_Demo/Demo_eng.htm

seems code is out of synchronization.
how to fix one?
Your LPT contains only 289 lines
210 lines for mode 256
1 line empty
27 lines in char mode
12 lines SYNC
39 lines empty (from top of the screen)

change
>CD20  FF 02 00 00 00 00 00 00  :........

>CDA0  D9 13 3F 00 00 00 00 00  :Y.?.....

to.
>CD20  F4 02 00 00 00 00 00 00  :........

>CDA0  CD 13 3F 00 00 00 00 00  :Y.?.....
Title: Re: Q&A
Post by: geco on 2016.January.07. 09:06:27
or it would be better to insert a new row between character lines and synchron into the original LPT

E9 02 3F 00 00 00 00 00  :........
Title: Re: Q&A
Post by: Zozosoft on 2016.January.07. 10:03:36
Now I writing small game on basic.
What is this source? It is look as assembly not as BASIC :oops:
Title: Re: Q&A
Post by: g0blinish on 2016.January.07. 10:04:59
yes, changes works now. but pixels looks like a bricks ;)

What is a way to convert RGB values to EP mode?
Title: Re: Q&A
Post by: geco on 2016.January.07. 10:22:06
yes, changes works now. but pixels looks like a bricks ;)

What is a way to convert RGB values to EP mode?
Yes, because in 256 col mode one pixel is 4x larger than in 4 col mode.
RGB values of Enterprise:

Code: [Select]
Bit 7 6 5 4 3 2 1 0
    g0r0b0g1r1b1g2r3

If you want to convert a picture to enterprise and not to 256 Col mode, then EPIMGCONV is the best tool for it.
Title: Re: Q&A
Post by: g0blinish on 2016.January.07. 10:24:44
If you want to convert a picture to enterprise and not to 256 Col mode, then EPIMGCONV is the best tool for it.

yes, I see format nd description of rgb values. I have dump of picture (indexed values and palette - R,G,B) and now i am looking to conversion.

Title: Re: Q&A
Post by: IstvanV on 2016.January.07. 11:47:15
If you want to convert a picture to enterprise and not to 256 Col mode, then EPIMGCONV is the best tool for it.

Here is one of the pictures from the Col256 demo converted in various modes:

Original image
[attachthumb=1]

Col256
[attachthumb=2]

epimgconv 256-color mode (no interlace)
[attachurl=3]
[attachthumb=4]

epimgconv 16-color mode (no interlace)
[attachurl=5]
[attachthumb=6]

epimgconv attribute mode (interlace)
[attachurl=7]
[attachthumb=8]

yes, I see format nd description of rgb values. I have dump of picture (indexed values and palette - R,G,B) and now i am looking to conversion.

If the conversion can only be lossy, or it requires finding an optimized palette/bias on the EP, then one possible solution is to convert the data to an image format that is recognized by epimgconv, and then convert that. It supports the XPM format, which is simple text, so it can easily be created in a program you write, or even a text editor.

Otherwise, it could be converted with a small program or script written specifically for this conversion.
Title: Re: Q&A
Post by: g0blinish on 2016.January.07. 12:03:13
well, i try to create xpm.
Title: Re: Q&A
Post by: SlashNet on 2016.January.07. 14:15:04
What is this source? It is look as assembly not as BASIC :oops:
This is output of ZIPSRC tool from here (https://enterpriseforever.com/hall-of-fame/zzzip-integer-compiler/msg21770/#msg21770).
Basic src I'll show later, when it will be more or less ready.
Now I trying to make some changes in gameplay to shrink code.

Here some animated graphics:
[attachimg=1]

Based on my art http://pixeljoint.com/pixelart/81327.htm
Title: Re: Q&A
Post by: ssr86 on 2016.January.11. 11:10:34
Is there a way to programatically check for turbo mode (and of what kind/speed is it)?
Title: Re: Q&A
Post by: geco on 2016.January.11. 11:43:28
Is there a way to programatically check for turbo mode (and of what kind/speed is it)?
Yes, count the instructions in a frame, and in this way possible to decide if the program runs in an emulator, or on real machine also if it is a turbo EP.
My solution gives back 81h value in HL at 4 MHz 100h at 8 MHz, 200h at 16 MHz , and so on, but for this 14 lines should be defined into that LPB where the interrupt flag is set.
István's solution is much more flexible, you can find it in source of DTM player, or in multimedia pack, or in any game conversion by István.
Title: Re: Q&A
Post by: Zozosoft on 2016.January.11. 12:33:52
From my Quick memory test which is write the CPU speed at the startup screen:

At 38h:
Code: ZiLOG Z80 Assembler
  1. ROMIRQ            JP (IX)

Code: ZiLOG Z80 Assembler
  1.                 LD HL,0
  2.                 LD IX,IRQ1
  3.                 LD BC,30B4H
  4.                 OUT (C),B
  5.                 EI
  6.                 HALT
  7. IRQ1            LD IX,IRQ2
  8.                 OUT (C),B
  9.                 EI
  10. IRQW            INC HL
  11.                 JP IRQW
  12. IRQ2            DI
  13.                 LD BC,HL
  14.                 LD DE,1000
  15.                 CALL MUL_DE_BC
  16.                 LD BC,HL
  17.                 LD A,E
  18.                 LD DE,12485
  19.                 CALL DIV_ABC_DE
  20.                 OR A
  21.                 LD DE,6243
  22.                 SBC HL,DE
  23.                 JR C,NOTROUND
  24.                 INC C
  25. NOTROUND

Then you got Mhz*100 value in BC. Measurement code need to run in non waited memory.

In the real life these CPU speeds used: 4, 6, 7.12, 10 MHz.
Title: Re: Q&A
Post by: ssr86 on 2016.January.12. 03:19:29
Thanks.

Zozo, could you for completeness include the code for multiplication and division procedures :oops:
Title: Re: Q&A
Post by: IstvanV on 2016.January.12. 09:10:54
A single multiplication is enough actually, with this code after IRQ2:
Code: ZiLOG Z80 Assembler
  1.         ld      de, 8
  2.         add     hl, de
  3.         ld      c, l
  4.         ld      b, h
  5.         ld      l, d
  6.         ld      h, d
  7.         ld      de, 5249
  8.         ; BCHL = BC * DE
  9.         ld      a, 16
  10. l01:    add     hl, hl
  11.         rl      c
  12.         rl      b
  13.         jr      nc, l02
  14.         add     hl, de
  15.         jr      nc, l02
  16.         inc     bc
  17. l02:    dec     a
  18.         jr      nz, l01
The constants 8 and 5249 may need to be tweaked for the most accurate result.
Title: Re: Q&A
Post by: g0blinish on 2016.January.12. 09:24:47
http://map.grauw.nl/sources/external/z80bits.html

seems here is an error with multiplication with squares
Title: Re: Q&A
Post by: Zozosoft on 2016.January.12. 09:32:00
Thanks.

Zozo, could you for completeness include the code for multiplication and division procedures :oops:

Code: ZiLOG Z80 Assembler
  1. MUL_DE_BC       LD HL,0
  2.                 SLA E
  3.                 RL D
  4.                 JR NC,MUL1
  5.                 LD H,B
  6.                 LD L,C
  7. MUL1            EXX
  8.                 LD B,15
  9. MUL2            EXX
  10.                 ADD HL,HL
  11.                 RL E
  12.                 RL D
  13.                 JR NC,MUL3
  14.                 ADD HL,BC
  15.                 JR NC,MUL3
  16.                 INC DE
  17. MUL3            EXX
  18.                 DJNZ MUL2
  19.                 EXX
  20.                 RET
  21. DIV_ABC_DE      LD HL,0
  22.                 EXX
  23.                 LD B,24
  24. DIV1            EXX
  25.                 ;DB 0CBH,31H ;SLL C
  26.               SLA C
  27.               SET 0,C
  28.                 RL B
  29.                 RLA
  30.                 ADC HL,HL
  31.                 SBC HL,DE
  32.                 JR NC,DIV2
  33.                 ADD HL,DE
  34.                 DEC C
  35. DIV2            EXX
  36.                 DJNZ DIV1
  37.                 EXX
  38.                 RET
Title: Re: Q&A
Post by: IstvanV on 2016.January.13. 13:37:34
Using these routines, it is possible to optimize the code somewhat as shown above. Instead of
Code: ZiLOG Z80 Assembler
  1.                 LD BC,HL
  2.                 LD DE,1000
  3.                 CALL MUL_DE_BC
  4.                 LD BC,HL
  5.                 LD A,E
  6.                 LD DE,12485
  7.                 CALL DIV_ABC_DE
  8.                 OR A
  9.                 LD DE,6243
  10.                 SBC HL,DE
  11.                 JR C,NOTROUND
  12.                 INC C
  13. NOTROUND

One can first add 6 (32768 / 5249) and then multiply by 5249 (65536 * 1000 / 12485). I added 8 instead to account for the time taken by the IRQ handler. The result is then in DE.
Code: ZiLOG Z80 Assembler
  1.                 LD BC, 6
  2.                 ADD HL, BC
  3.                 LD BC, HL
  4.                 LD DE, 5249
  5.                 CALL MUL_DE_BC
  6.                 LD BC, DE
C compilers on PC use similar tricks to replace division by a constant with multiplication, which is faster.
Title: Re: Q&A
Post by: ssr86 on 2016.January.14. 17:59:40
@IstvanV I saw that in your sprite example you were able to count the exact time of the drawing code. I hope it's not a stupid question to ask you for the principles of applying the waits to instruction timings... I guess it's based on the source/destination memory segment (if it has wait states) or is there another factor?

I'm asking because I'd need a way to limit the number of sprites drawn in a single frame. I thought that I could calculate the upper limit of the common code and then limit the number of sprites drawn in one frame to fit in single/double frame time. Then the sprites that wouldn't be drawn in the previous frame would get priority in the next frame. This would produce spriteflicker like on the nes but would allow to make the game in 50fps if chosen to... So I thought having the calculated available time (from Zozo and yours code) I would substract the cost of the common code (and/or optional code) and then while drawing the sprites I would substract their cost until I know I won't be able to draw more...

Maybe someone has another idea?

Well, I guess that an alternative would be to set an interrupt somewhere near the end of the frame where a marker would be set to inform that one cannot afford to draw more sprites.... However it's a less accurate way and that key code should be dealt with at the end of the frame which may not be the case...
Title: Re: Q&A
Post by: IstvanV on 2016.January.14. 18:49:24
@IstvanV I saw that in your sprite example you were able to count the exact time of the drawing code. I hope it's not a stupid question to ask you for the principles of applying the waits to instruction timings... I guess it's based on the source/destination memory segment (if it has wait states) or is there another factor?

Wait states generated by DAVE (if enabled on port BFh) are simple, they add 1 cycle to all memory accesses (00h) or only M1 reads (04h). The latter are the first byte of simple instructions with no prefix, or the first two bytes with CB/DD/ED/FDh prefix. Also, according to tests by Zozosoft, it seems that DAVE waits 2 cycles on turbo machines. But in programs where speed is important, wait states are disabled, so all the above does not matter.

Video memory and NICK I/O port timing are more complex: within each 889846 Hz "slot" (1 character), the Z80 is allowed access to one byte at a specific time, and it always needs to wait at least a certain amount of time (a few ns more than 5/16 of a character, and there is also few ns difference depending on the type of access - normal memory, M1 memory, and I/O). This is implemented by the NICK chip halting the Z80's clock, which it can do in 1/2 clock cycles (1/8000000 s on normal non-turbo machines). There is a test run on real machines here (https://enterpriseforever.com/emulatorok/idozitesi-problemak-az-emulatorokban/30/) that measures the average time between video memory accesses at various intervals in Z80 cycles.

For the calculations in the sprite code, I used a simplified model: add 1.5 cycles to the time between the video memory accesses, and then round up the result to an integer multiple of 4.5 cycles, and that is the real amount of time, with the wait states (stopped Z80 clock) added. In other words, the best case is 1.5 cycles of wait, and the worst case is 5.5 cycles. This is not entirely accurate, but it gives a reasonable estimate.

When calculating video memory timing, it should also be taken into account exactly when the accesses occur within the instruction. This can be found in the Z80 documentation. For example, an LD (HL), A instruction is two memory accesses, an M1 read at 2 cycles, and a normal write at 6.5 cycles.
Title: Re: Q&A
Post by: ssr86 on 2016.January.22. 11:33:33
@IstvanV
Could you fill such table:
Code: [Select]
|read memory type|write memory type| M1 delay| read delay| write delay| io read delay| io write delay|
It's for a person that is writing a z80 profiler so maybe he could add an enterprise mode.
Title: Re: Q&A
Post by: ssr86 on 2016.April.24. 12:22:45
Is someone able to provide some working examples/routines for doing some ingame sound effects (noise-based or any other). I'd be really grateful.
Title: Re: Q&A
Post by: geco on 2016.April.24. 19:15:21
I can provide you digi effects only, other possibility to take out  effects from games, or if someone creates effects in basic then it could be adapted into your game without EXOS calls, I created a small routine which save DAVE registers during Basic sound playback, I could insert I Love Rock'n'Roll into Bricky Prise with this solution.
Title: Re: Q&A
Post by: ssr86 on 2016.April.24. 23:56:17
hmm...
I dont really know how to take out sounds from games as I don't know what to look for. Maybe I could achieve something from basic... So I would appreciate the routine you mentioned.
My problem is I've never done sound effects so I don't really know how to achieve what I'm looking for...
Time is running out for the deadline and I feel I need to do some shortcuts to actually complete something...
Title: Re: Q&A
Post by: IstvanV on 2016.April.25. 13:12:16
For experimenting with DAVE sound generators, there is a davetest (https://enterpriseforever.com/letoltesek-downloads/pc-utils/?action=dlattach;attach=6761) utility that lets you try all the effects.

I created a small routine which save DAVE registers during Basic sound playback, I could insert I Love Rock'n'Roll into Bricky Prise with this solution.

I used a somewhat similar solution with a Lua script to capture the music from Enterball (https://enterpriseforever.com/jatekok/enterball/msg21194/#msg21194) for the Spectrum 128 conversion. This could be modified (and simplified) for playback on the Enterprise, although the file format is not very efficient, the converted Enterball music takes up almost 4 KB.
Title: Re: Q&A
Post by: geco on 2016.April.25. 15:51:43
You can try to ask Szipucsu, or Endi to create effects, they played a lot with sounds, if you have the sounds and you did not use Istvan's solution, then you can send me the snapshots, and i will give you the raw data, i can share also the code, but it is only a direct assembly to EP128emu as I remember, and when you entered it dave registers save starts
Title: Re: Q&A
Post by: ssr86 on 2016.April.26. 08:35:31
The davetest doesn't help uch as you can't change the envelope etc.
What about the possibility to port ay sfx? Is it doable and pretty straightforward?
If I won't be able to get it done in basic or ay then I guess I'll ask szipucsu or endi...
I'd also want to learn how it's done...

I'll once again switch to other things then... as there is still quite a lot to do...
Title: Re: Q&A
Post by: geco on 2016.April.26. 08:41:54
AY SFX can be ported also, snd if you have some with sources, it would be the easiest one.
Title: Re: Q&A
Post by: ssr86 on 2016.April.26. 09:13:20
I've googled this ayfxedit from http://shiru.untergrund.net/files/ayfxedit04.zip but I'm currently at work so can't really test it. But it seems to have many example effects from games. Anyone could tell me how to port the spectrum sfx to ep? Is there a tool for this?
Title: Re: Q&A
Post by: geco on 2016.April.26. 10:16:32
I've googled this ayfxedit from http://shiru.untergrund.net/files/ayfxedit04.zip but I'm currently at work so can't really test it. But it seems to have many example effects from games. Anyone could tell me how to port the spectrum sfx to ep? Is there a tool for this?
Are they contain only sound RAW data, or data + player assembly?
if it contains the player also, then you should insert to the player István's AY emulation routine, if it does not contain player, just raw data, then there are 2 possibilities, convert the data to DAVE and create a simple player, or does not convert, create a simple player for AY, and insert István's AY emulation routine.
Title: Re: Q&A
Post by: geco on 2016.April.26. 10:25:50
As I see, there are samples in RAW data, and separately the code of the player, so 2 possibilities are available :)
If you have the samples, I can help to make one solution.
Title: Re: Q&A
Post by: endi on 2016.April.26. 10:34:28
if you want basic/exos (sound:) sfx, you must wait for my new sfx creator tool :)
Title: Re: Q&A
Post by: geco on 2016.May.17. 09:02:51
Today we closed the possibility of entering a program, now we should start the voting.
First question: How many category should we keep, because we have only one entry in Wild category, should we close Wild, and keep 2 categories (conversion, EP program), or we should change Wild to Basic, and move Flora to EP program (EP program, Conversion, Basic)?
How should we organize the voting, all program should be scored between 1-10 points, or only the 1st, or the first three should be chosen?
If you wish to increase the fund of prize, you can do it (even for a special category), SSR86 is the owner :)
Title: Re: Q&A
Post by: ssr86 on 2016.May.17. 09:37:01
hmmm... I think we should close the wild and instead do basic. As for the voting, we should be able to score each entry from 1-10. Then we compare the average score for each entry. At least that was the first idea...
Title: Re: Q&A
Post by: geco on 2016.May.17. 19:56:16
Voting (https://enterpriseforever.com/enterprise-devcompo-39/enterprise-devcompo-1-voting-szavazas/) can be done here, the format can be changed, I hope it will go to a better visible place, in this moment I could create it there.
Title: Re: Q&A
Post by: ssr86 on 2016.November.16. 14:32:42
Anyone fancy for another try?
Rules more or less the same (although looking back at the first edition there need to be some minor changes made), however if there wouldn't be any objections I'd like to limit the original categories to productions with blocky graphic modes (like 160x128 with 2x2 pixels, 80x64 4x4pixels or similar) because I think that there's a lot of potential in these graphic modes (I know I'm being quite egoistic here).
Title: Re: Q&A
Post by: endi on 2016.November.16. 14:47:10
Anyone fancy for another try?
Rules more or less the same (although looking back at the first edition there need to be some minor changes made), however if there wouldn't be any objections I'd like to limit the original categories to productions with blocky graphic modes (like 160x128 with 2x2 pixels, 80x64 4x4pixels or similar) because I think that there's a lot of potential in these graphic modes (I know I'm being quite egoistic here).

or GraCha graphics-character modes? :)
Title: Re: Q&A
Post by: ssr86 on 2016.November.16. 15:10:18
as long as you repeat the screen lines so the pixels will appear square ;)
The 2x4-color char mode is very good for the blocky modes imo. Maybe the lpt is twice the size as you can't use vres but you get a boost in background draw time and you can do a lot of char-based animation. You still can do sprites but you need to sacrifice some characters from the set... etc...
Title: Re: Q&A
Post by: geco on 2016.November.16. 17:09:17
From my side we can start the 2nd attempt :)
Title: Re: Q&A
Post by: gflorez on 2016.November.16. 18:10:36
Think on mouse control when creating a game...
Title: Re: Q&A
Post by: geco on 2016.November.17. 08:34:54
Or we can make a separate category for blocky games.
Should we set start date to 1st of december and end date to 16 of may?
If these are clarified, I will start to promote it on Pouet, CPC and Speccy forum.
Title: Re: Q&A
Post by: Zozosoft on 2016.November.17. 08:45:49
Or we can make a separate category for blocky games.
Better idea. I don't want to close out anything new :-)
Title: Re: Q&A
Post by: ssr86 on 2016.November.17. 10:17:07
I think that the first edition showed that there's no sense in having more categories. I'd even considered having no categories and have more awarded places based on funds.
Let's abandon the "blocky" restriction - that was just an idea to somewhat promote these modes (inspired by looking at so many beautiful pico8 and gameboyjam games).
However I will consider awarding a small private bonus to the blocky productions I like ;P.

Should we set start date to 1st of december and end date to 16 of may?
If these are clarified, I will start to promote it on Pouet, CPC and Speccy forum.
Yeah, these dates are ok. To tell you the truth I was really disappointed and down about the lack of real interest from the outside so I don't really believe that this time it will be different but maybe Shadow's demo changed something...
Title: Re: Q&A
Post by: endi on 2016.November.17. 10:29:49
"gracha" mode is good for some extra things:
-fast scroll (but with character step of course)
-multi layer scroll (parallax)
-fast change of graphics tiles on full screen
-using big sprites

there are many spectrum games with virtual character mode, with scroll and bit characters. so this is possible in this gracha mode, but with 10x speed!
Title: Re: Q&A
Post by: geco on 2016.November.17. 10:30:35
I think that the first edition showed that there's no sense in having more categories. I'd even considered having no categories and have more awarded places based on funds.
Let's abandon the "blocky" restriction - that was just an idea to somewhat promote these modes (inspired by looking at so many beautiful pico8 and gameboyjam games).
However I will consider awarding a small bonus to the blocky productions, I like ;P.
One category also a good idea, and we can set special prices for blocky games, ex best 3 blocky game get additional award.
Yeah, these dates are ok. To tell you the truth I was really disappointed and down about the lack of real interest from the outside so I don't really believe that this time it will be different but maybe Shadow's demo changed something...
I was also disappointed, but now i do not have big expectation :D , so i will be happy if anybody joins from outside.
I do not think that Shadow's great demo made changes in interest, but I hope he will join :)
Title: Re: Q&A
Post by: ssr86 on 2016.November.17. 10:44:22
Ok Geco, so if no one is against it - no categories and additional bonus award/awards for blockiness (but maybe these should be private on my part as this was "put" by me...). So basic games, cpc/speccy ports and "originals" (written from scratch in assembly - that doesn't mean you can't use resources from other platforms or do a "clone" of a game you like) all compete together. We need at least two more opinions on this.
Title: Re: Q&A
Post by: geco on 2016.November.17. 13:32:32
ok, I will try to move the infos to Hungarian topic also, from my point of view we can assign a specific amount of money based on our balance to blocky games, if nobody against it.
Title: Re: Q&A
Post by: Zozosoft on 2016.November.18. 11:43:19
One idea: make a videos of best programs of DevCompo #1, and these can be linked in DevCompo #2 advertisment as examples.
Title: Re: Q&A
Post by: geco on 2016.November.18. 13:28:54
One idea: make a videos of best programs of DevCompo #1, and these can be linked in DevCompo #2 advertisment as examples.
Good idea, but who will make the videos? :)
Title: Re: Q&A
Post by: szipucsu on 2016.November.18. 17:31:57
Good idea, but who will make the videos? :)
Quite easy:
1 - start EP128Emu
2 - load the game
3 - start video capture
4 - play the game
5 - stop video capture
6 - upload video to youtbe

We could create a Youtube channel with the name e.g. Enterpriseforever forum and upload there everything connected to the forum.
Title: Re: Q&A
Post by: Zozosoft on 2016.November.18. 19:42:57
Good idea, but who will make the videos? :)
SlashNet? He are professional in videos making (https://www.youtube.com/playlist?list=PLyuEnSWHiyJt37qckGpri-F45AuZh8Ar0)!
SlashNet! What are you think about this idea?
Title: Re: Q&A
Post by: SlashNet on 2016.November.18. 21:50:45
Need to think. :)
I can, but only from next week.
This weekend I want to rest (I had "hard day's night"-month). :smt095 :smt079
Title: Re: Q&A
Post by: g0blinish on 2016.November.20. 19:55:37
back again to devcompo#2:

how to define colors at LPT for mode 16colors?
Title: Re: Q&A
Post by: ergoGnomik on 2016.November.20. 20:15:58
back again to devcompo#2:

how to define colors at LPT for mode 16colors?
The last 8 bytes of each LPB are the colours 0..7 in the part of the screen defined by the given LPB. Colours 8..15 are generated from colours 0..7 and the BIAS register of the NICK. This (http://ep.homeserver.hu/Dokumentacio/Konyvek/EXOS_2.1_technikal_information/index.html) book probably tells everything better than I ever could.
Title: Re: Q&A
Post by: Zozosoft on 2016.November.20. 20:19:27
how to define colors at LPT for mode 16colors?
You can define only the first 8 in each LPT lines. Other 8 are definied by the Fix Bias register, and it is valid for the whole screen. But you can change it anytime, then timed or IRQ based Bias change trick possible for use different Bias on different screen areas. But it is need a more CPU time.
Title: Re: Q&A
Post by: g0blinish on 2016.November.21. 10:50:59
hmm. yes, i read Nick docs, but I messed into one:(
Anyway, Idea is to get only 16 colours.


Title: Re: Q&A
Post by: geco on 2016.November.21. 11:06:33
hmm. yes, i read Nick docs, but I messed into one:(
Anyway, Idea is to get only 16 colours.
Mode byte in LPB should be 52h if you want to use 16 colour 160x200 reso, 14h if you want to use attribute screen.
you can freely chose 8 colours, just insert the colour codes into 8-15 byte of LPB, the last 8 colours can not be choose freely, you can chose from 32x8 colour group by bias register 80h.
Title: Re: Q&A
Post by: g0blinish on 2016.November.21. 11:16:36
Mode byte in LPB should be 52h if you want to use 16 colour 160x200 reso,

so, 160x200 is limited resolution?
Title: Re: Q&A
Post by: geco on 2016.November.21. 11:22:21
so, 160x200 is limited resolution?
in the reality it is not limited to 160x200 (max screen size in this case 184x300), but yes when you use 16 colour and Pixel mode then the horizontal size of the pixel is doubled, in attribute mode you can use 16 colours and normal pixel size.
Title: Re: Q&A
Post by: g0blinish on 2016.November.22. 06:00:18
some info for EC0-EC3 lead to error 404:
http://ep.lgb.hu/doc/Nick.html#FIXBIAS

how to define colors?
Title: Re: Q&A
Post by: lgb on 2016.November.22. 08:50:50
some info for EC0-EC3 lead to error 404:
http://ep.lgb.hu/doc/Nick.html#FIXBIAS

how to define colors?

That site is only my "mirror" of some of the pages, missing other pages it links to ... But EC0-EC3 is not important for you anyway, it's about the bus expansion port, that there can be external hardware device, EC=External Colour. What is important for the BIAS from register 80h are the lower 5 bits.
Title: Re: Q&A
Post by: geco on 2016.November.22. 08:52:49
You can do it in the beginning of your code by the following EXOS call, until EXOS interrupt is active:
Code: [Select]
               LD BC,100H+28 ;B=1 write
;C=28 number of system variable (BIAS)
                LD D,0c0h ;new value
                EXOS 16 ;handling EXOS variable

If EXOS interrupt killed then:
Code: [Select]
        ld      a,color/8
         out   (80h),a

I wrote color/8, becuase EXOS call and direct write to BIAS register is different, BIAS is grouped by 8 colours,
0 th group: 0-7
1 st group: 8-0fh
2 nd group:10h-17h
...
31th group: f8h-ffh

You can use the colour numbers for EXOS BIAS call, but the bias will be the same when you select 0 or when you select 5.
When you enter BIAS directly by register you select the group identifiers, if you select 2 then last 8 color of the palette will be the following:
10h,11h,12h,13h,14h,15h,16h,17h
Title: Re: Q&A
Post by: Zozosoft on 2016.November.22. 08:57:31
If not needed any fast BIAS changing trick in the program then I recommend using EXOS variable setting.
-you can use normal color code (which 8 colors block contain the selected color will be used)
-don't change the internal speaker state in Nick
Title: Re: Q&A
Post by: g0blinish on 2016.November.22. 09:25:11
well, result isn't what i expected for :(
Title: Re: Q&A
Post by: ssr86 on 2016.November.22. 10:22:48
Looking at your 16c.asm:
Code: [Select]
LPT:        DB -200 ;200 lines
            DB VRES+C16+PIXEL
;            DB VRES+C4+PIXEL;32H  ;0 01 1 001 0
                    ;VINT=0, no IRQ
                    ;Colour Mode=01, 4 colours mode
                    ;VRES=1, full vertical resolution
                    ;Video Mode=001, pixel graphics mode
                    ;Reload=0, LPT will continue

            DB 11   ;left margin=11
            DB 51   ;right margin=51
VIDCIM1:    DW 0    ;primary video address, address of pixel data
            DW 0    ;secondary videó address, not used in pixel graphics mode

PALETTE:;    DB 0,$34,$3A,$3d,0,0,0,0

;;;;;;;;;;;;;;;;;;;;;;;; db 0,1,2,3,4,5,6,7  

            DB -50,12H,63,0,0,0,0,0,0,0,0,0,0,0,0,0
               ;50 lines of border, this is the bottom margin,

            DB -3,16,63,0,0,0,0,0,0,0,0,0,0,0,0,0
               ;3 black lines, syncronization off

            DB -4,16,6,63,0,0,0,0,0,0,0,0,0,0,0,0
               ;4 lines, syncronization on

            DB -1,90H,63,32,0,0,0,0,0,0,0,0,0,0,0,0
               ;1 line, syncronization will switch off at half of line
               ;the NICK chip generate video IRQ at this line

            DB 252,12H,6,63,0,0,0,0,0,0,0,0,0,0,0,0
               ;4 black lines

            DB -50,13H,63,0,0,0,0,0,0,0,0,0,0,0,0,0
               ;50 lines of border, this is the top margin,
You should erase the line that I marked with ";;;;;;;;;;;;;;;;;;". Like the others already said - in the lpt you give only the first 8 colors. The other 8 are determined by a single write to the fixbias register ($80) and are not arbitrary but you choose a group of 8 colors from 32 possible combinations.
Title: Re: Q&A
Post by: IstvanV on 2016.November.22. 10:45:53
It is not related to the palette issue, but if you do not use double buffering, then it can be beneficial to generate the video interrupt at the beginning of the bottom border instead of at VSYNC, this way you get the most time to update the screen without flickering or other artifacts. Since the interrupt is triggered only after the LPB with the VINT bit set, in this particular case it would need to be set on the first (200 lines long) LPB.

You can do it in the beginning of your code by the following EXOS call, until EXOS interrupt is active:
Code: [Select]
                LD BC,100H+28 ;B=1 write
;C=28 number of system variable (BIAS)
                LD D,0c0h ;new value
                EXOS 16 ;handling EXOS variable

Also, if interrupts are disabled soon after this EXOS call, it is best to execute two HALT instructions after the EXOS 16 to make sure the new BIAS is really set.

If not needed any fast BIAS changing trick in the program then I recommend using EXOS variable setting.

Using EXOS variables does have one disadvantage: the new setting will remain in effect even after quitting the program, unless it is set to zero again in the reset routine. Programs that exit to the EP logo with a non-black border color can be annoying, BIAS is mostly an issue with some badly written games (old Spectrum conversions) that assume it is zero.
Title: Re: Q&A
Post by: SlashNet on 2016.November.26. 19:31:33
1 - start EP128Emu
2 - load the game
3 - start video capture
4 - play the game
5 - stop video capture
6 - upload video to youtbe
Made:
Wall Defender game: https://www.youtube.com/watch?v=NB1i_zMLrL0
Bomber 3 in 1: https://www.youtube.com/watch?v=C_52WgnS9A0
FlapFlap game: https://www.youtube.com/watch?v=Qv3zW139W3o
Jumprise: https://www.youtube.com/watch?v=rbPJps_PBco
Snaki: https://www.youtube.com/watch?v=cLZgEk5KsYs
Lirus: https://www.youtube.com/watch?v=Xa8WPSryFUk
Filler: https://www.youtube.com/watch?v=rWjYW-KRo4U
Pacman: https://www.youtube.com/watch?v=RZ0gQkF9Xlg
Chase H.Q.: https://www.youtube.com/watch?v=WXCk-lGaKbM
ZenLoops: https://www.youtube.com/watch?v=4wB83Wzmwu4
Bricky Prise: https://www.youtube.com/watch?v=-q8d8XWXnyA
Flora: https://www.youtube.com/watch?v=MVjewU5p4-M

For Team Hat Trick aka Six Men One Puck, I think existing video (https://www.youtube.com/watch?v=4qmOwGM5LZc) is quite informative.
Title: Re: Q&A
Post by: Zozosoft on 2016.November.26. 19:41:59
Great work, thanks!
Title: Re: Q&A
Post by: geco on 2016.November.26. 20:35:14
Cool, thank you very much. You were very fast :)