Welcome, Guest. Please login or register.


Author Topic: How to begin assembly on Enterprise (Read 29185 times)

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: How to begin assembly on Enterprise
« Reply #15 on: 2014.June.13. 20:37:58 »
If you do not understand something do not hesitate to ask!


What do you think about rename your first topic as "EP assembly for beginers" or something? And can continue talking about sample.asm or any other questions about how to begin.

Offline ssr86

  • EP user
  • *
  • Posts: 355
  • Country: pl
Re: How to begin assembly on Enterprise
« Reply #16 on: 2014.June.14. 12:26:25 »
Quote
What do you think about rename your first topic as "EP assembly for beginers" or something? And can continue talking about sample.asm or any other questions about how to begin.
I think it'd be not a bad idea:).

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: How to begin assembly on Enterprise
« Reply #17 on: 2014.June.14. 12:33:19 »
Done :-)

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: How to begin assembly on Enterprise
« Reply #18 on: 2014.June.15. 11:18:01 »
Quote from: lgb
I am not sure though what happens if an LPB is for multiple scanlines: is the LPB re-read anyway on each scanline, or not?
It is re-read on every line.

Offline gflorez

  • EP addict
  • *
  • Posts: 3607
  • Country: es
    • Támogató Támogató
Re: How to begin assembly on Enterprise
« Reply #19 on: 2014.June.15. 12:01:11 »
What can happen if I do an OUT to a non-existent port?

I'm playing with the SERIAL driver(I've disassembled the driver)....and want to clone the READ CHARACTER call.

I need to maintain DTR (bit 1 on port 0xB7)  to the same value during all the call, but the stock subroutine has hand-shake, not needed to communicating with a Microsoft mouse....(I know, I know is a waste of time but this is only for my amusement....).

By the way, I have connected successfully the Microsoft serial mouse directly to the EP, only four cables needed, powering itself from the data lines. But the problem is, every time DTR changes, the mice sends an ASCII "M"(mouse, as opposed to "K" keyboard), that is mixed with the information the mouse was previously sending, resulting in some garbage....

Then it is required the same timing and I can't replace OUT (0xB7),A (11 clock cycles) with  three NOPs (12 clock cycles).

Can I replace it with, for example, OUT (0x00),A?
« Last Edit: 2014.June.15. 12:24:11 by gflorez »

Offline ssr86

  • EP user
  • *
  • Posts: 355
  • Country: pl
Re: How to begin assembly on Enterprise
« Reply #20 on: 2014.June.15. 15:22:44 »
1. How do I wait for the vertical retrace?
2. How can I turn off the OS? (or is it actually a bad idea?) The system calls complicate the code somewhat...and I have a feeling that the majority of games have it turned off (like the Amstrad's firmware on the CPC)...
3. Why in all (three) example codes I've seen, the interrupts are disabled somewhere at the beginning of the program and never turned on later in the code (implicitly).
 
And two not strictly-programming-related questions:
1. Where can I find a tracker (preferably a PC one...) for enterprise's sound chip?
2. Where can I find a palette reference for the enterprise? (I saw the formula for the colors in the docs and generated the palette to see, but maybe there's a table with possible gradients and stuff (maybe some example 16-color palettes to see how the bias system works visually, what constraints does it pose)?)

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: How to begin assembly on Enterprise
« Reply #21 on: 2014.June.15. 16:37:57 »
Quote from: gflorez
What can happen if I do an OUT to a non-existent port?

Can I replace it with, for example, OUT (0x00),A?
I think nothing happens and you can do it, but if you substitute with CP (HL) and CP H it is also 2 bytes, and 11 clock cycles.

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: How to begin assembly on Enterprise
« Reply #22 on: 2014.June.15. 16:48:05 »
Quote from: ssr86
1. How do I wait for the vertical retrace?
Put the interrupt request the previous LPB of Vertical retrace LPB, the interrupt will occure at retrace LPB.

Quote from: ssr86
2. How can I turn off the OS? (or is it actually a bad idea?) The system calls complicate the code somewhat...and I have a feeling that the majority of games have it turned off (like the Amstrad's firmware on the CPC)...
You do not need to turn off it, it is enough to page out it, and make an own interrupt routine, do not forget to set the right latch and divider bits of port 0b4h in the interrupt ,in case of video interrupt:
Code: [Select]
    ld   a,30h
    out  (0b4h),a
If it is not done, then the interrupt flag is not deleted, and the machine remains interrupt request loop.

Quote from: ssr86
3. Why in all (three) example codes I've seen, the interrupts are disabled somewhere at the beginning of the program and never turned on later in the code (implicitly).
I do not know, it is not necessary to turn off it, the stack pointer has to be set.
Quote from: ssr86
And two not strictly-programming-related questions:
1. Where can I find a tracker (preferably a PC one...) for enterprise's sound chip?
2. Where can I find a palette reference for the enterprise? (I saw the formula for the colors in the docs and generated the palette to see, but maybe there's a table with possible gradients and stuff (maybe some example 16-color palettes to see how the bias system works visually, what constraints does it pose)?)
Unfortunately there is no PC tracker, only tracker on EP.
I do not know if it exists, but I can do a palette only for bias values if it is good for you.
« Last Edit: 2014.June.15. 16:54:47 by geco »

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: How to begin assembly on Enterprise
« Reply #23 on: 2014.June.15. 21:59:32 »
Quote from: IstvanV
It is re-read on every line.

And are the possible changed values used? I mean an LPB can be valid for - let's say - 10 scanlines. What happens if I alter even the number of scanlines parmeter in the LPB and it's re-read by Nick on the next scanline. The other parameters (margins etc) are easier to imagine that will be used, but this made me thinking a bit. As far as I can imagine, that parameter won't cause any effect as number of scanlines for a given LPB should be a counter inside the Nick anyway.

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14723
  • Country: hu
    • http://enterprise.iko.hu/
Re: How to begin assembly on Enterprise
« Reply #24 on: 2014.June.15. 22:32:24 »
Quote from: ssr86
2. How can I turn off the OS? (or is it actually a bad idea?)
It is very bad idea write EXOS incompatible program!
Unfortunatelly no focus is placed about the right EXOS compatible programming at the start :cry: The Enterprise have really good, expandable operating system. (At the release time it is better than the MS-DOS!) Then many different configuration can be exist. At the start years exist a 64 and 128K, English and German machines, later these combined with EXDOS card.
And under the many years, many-many-many... RAM, ROM and other expansion created, Hard Disk system, and in current days SD Card systems.
In the expandable EXOS system many things are at variable address! Fix programing like as C64 or ZX Spectrum are bad idea on Enterprise!

With the bad programmed, EXOS incompatible programs (using fix address), found many-many problems under the years. For example running only on just English or just German machine, only with 128K, not running with memory expansion. Not running from floppy. Running from hard disk destroy Hard Disk extension RAM area and generate data loss, etc...

Many bad programs fixed, and continously fixing these. And at about the last ten years we care about all new programs are EXOS compatible then no new problem created :-)

From the practical side:
The most important things:
- don't use any memory what you not allocated from EXOS! EXOS 24 call the allocation.
- check errors (after memory allocation, or file operations) and if error use regular exit routine for step back to EXOS
- handle variable segment numbers, at general RAM only need store to paging table, with video segments also needed to calculate video address from the segment number
-specify warm start routine (restart program or exit)

All of these are included in the sample.asm! You need just write the main code! :-)

If you can specify which memory paging, and which video mode needed for you then I can modify the sample for your requirements!


If you will write game or demo you will use New Application Program type with header 05h.
It is loaded from 0100h...
Under the 0100h EXOS only use 0030h-005Bh area. Then 0000h-002Fh area can be used by the user programs, usualy for RST 00h-28h routines. 005Ch-00FFh also can be used, many programs use as stack under 0100h.

Generaly demos/games don't use EXOS during the running, use it only for file I/O, and memory allocation. EXOS IRQ routine can be replaced (placing jump to 38h) but it is needed to restored before EXOS calls used (for example load next level in the game), or exit program.
If you directly programing the HW then need to disable EXOS interrupts, or define your own IRQ routine and replace the EXOS IRQ.

So, generaly don't need switch of OS, just don't use it under the main program.

Offline gflorez

  • EP addict
  • *
  • Posts: 3607
  • Country: es
    • Támogató Támogató
Re: How to begin assembly on Enterprise
« Reply #25 on: 2014.June.15. 22:48:32 »
To Geco:

There are some Z80 instructions lasting 11 time cycles, the lenght is not so important as this is new code, but unfortunately all of them can affect the flags or capital registers inside some nested loops.

Also a 7 cycles instruction plus a NOP doesn`t suits.

I think I will try the inexistent port OUT instruction or try to change previously the value of register A....18 times.

Thanks..

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: How to begin assembly on Enterprise
« Reply #26 on: 2014.June.16. 08:59:27 »
Quote from: gflorez
To Geco:

There are some Z80 instructions lasting 11 time cycles, the lenght is not so important as this is new code, but unfortunately all of them can affect the flags or capital registers inside some nested loops.

Also a 7 cycles instruction plus a NOP doesn`t suits.

I think I will try the inexistent port OUT instruction or try to change previously the value of register A....18 times.

Thanks..
I thought that the flag register is not important, it will be modified later :oops:

Offline ssr86

  • EP user
  • *
  • Posts: 355
  • Country: pl
Re: How to begin assembly on Enterprise
« Reply #27 on: 2014.June.16. 15:48:32 »
Quote
All of these are included in the sample.asm! You need just write the main code!
..and that's why it is harder for me to read it... But I guess I shouldn't worry too much about the setup part and just get to the main code...

Quote
If you can specify which memory paging, and which video mode needed for you then I can modify the sample for your requirements!
Thanks, but I actually managed to get those code samples I've written for those blocky modes to work within the sample.asm.

About ensuring exos compatibility... is this enough:
Quote
(...) don't use EXOS during the running, use it only for file I/O, and memory allocation. EXOS IRQ routine can be replaced (placing jump to 38h) but it is needed to restored before EXOS calls used (for example load next level in the game), or exit program.
As for replacing the interrupt handler... will this be enough (as a dummy interrupt)?:
Code: [Select]
;; set interrupt
ld a,&c3        ; c3 = jp opcode
ld hl,Interrupt
ld (&0038),a
ld (&0039),hl

;; ...
;; and later...
.Interrupt:
   di
   ld a,30h
   out (0b4h),a
   ei
   ret

I suppose it is a stupid question...but...
I set up the virq in my LPT and now...how do I check for this video interrupt at the beginning of my program's mainloop? 
I am looking for a equivalent of amstrad's:
Code: [Select]
.FrameFlyB
    ld b,&f5
.FFBLoop
    in a,(c)
    rra
    jr nc,FFBLoop
    ret

@geco
Quote
Unfortunately there is no PC tracker, only tracker on EP.
I "checked" what I could find (not much)... Which is the most user friendly?
"Music Box" has a lot of example tunes to load...but how do I do that in the emulator? I use the fileIO but I get an "drive A" error...
Quote
I do not know if it exists, but I can do a palette only for bias values if it is good for you.
Thank you, but I don't want to waste your time. I should be able to do that on my own.

Offline geco

  • EP addict
  • *
  • Posts: 7082
  • Country: hu
    • Támogató Támogató
Re: How to begin assembly on Enterprise
« Reply #28 on: 2014.June.16. 16:20:30 »
Quote from: ssr86
About ensuring exos compatibility... is this enough:As for replacing the interrupt handler... will this be enough (as a dummy interrupt)?:
Code: [Select]
;; set interrupt
ld a,&c3        ; c3 = jp opcode
ld hl,Interrupt
ld (&0038),a
ld (&0039),hl

;; ...
;; and later...
.Interrupt:
   di
   ld a,30h
   out (0b4h),a
   ei
   ret
Yes, and the DI inside the interrupt is not necessary.

Quote from: ssr86
I suppose it is a stupid question...but...
I set up the virq in my LPT and now...how do I check for this video interrupt at the beginning of my program's mainloop?
I am looking for a equivalent of amstrad's:
Code: [Select]
.FrameFlyB
    ld b,&f5
.FFBLoop
    in a,(c)
    rra
    jr nc,FFBLoop
    ret
You can do it with a simple HALT instruction if interrupt is not disabled or
Code: [Select]
chk50hz  in   a,(0b4h)
         bit  4,a
         jr   z,chk50hz
Quote from: ssr86
@gecoI "checked" what I could find (not much)... Which is the most user friendly?
"Music Box" has a lot of example tunes to load...but how do I do that in the emulator? I use the fileIO but I get an "drive A" error... Thank you, but I don't want to waste your time. I should be able to do that on my own.
Music box is the most user friendly, but if I remember well you are not able to use all effects ( may be I have wrong )
FileIO is a good setting, just tick in emulator menu in Configure ... the Enable Virtual file I/O.

It is not a big issue, every bias is started at at bias value*8 on the palette, so
Bias 0 : col00 - col07
Bias 1 : col08 - col0f
...
Bias 1f: colf8 - colff

Offline ssr86

  • EP user
  • *
  • Posts: 355
  • Country: pl
Re: How to begin assembly on Enterprise
« Reply #29 on: 2014.June.16. 17:29:49 »
Quote
You can do it with a simple HALT instruction if interrupt is not disabled or
Oh, I thought that the z80 in interrupt mode 1 triggers six interrupts per frame.. :oops:(300Hz)...but that seems to be true only for the amstrad? Just read that on the spectrum
Quote
is triggered at the start of the vertical blank period of the screen refresh. This cannot be changed

And for the enterprise?
The only interrupt is virq, but can be triggered every second line of display?
Quote
You can do it with a simple HALT
...Actually the first thing I tried earlier was a halt...but then it didn't work...Commented some code and now it works...:oops: