Welcome, Guest. Please login or register.


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

Offline ssr86

  • EP user
  • *
  • Posts: 355
  • Country: pl
Re: How to begin assembly on Enterprise
« Reply #45 on: 2014.October.08. 16:38:57 »
What is the role of left/right margin in the sync lines? Because I looked at the few examples I gathered and there are other values written...
I mean the example found in one of the exos manuals:
Code: [Select]
; PIXEL for 256 lines (4 color)
DB    256-256,pixel+c4+vres,14,14+32
DW    screen,0
DB    0,1,2,3,4,5,6,7

;blank for 5 lines               ; bottom margin
DB    256-5,lpixel,63,0
DB    0,0,0,0,0,0,0,0,0,0,0,0

;black for 10 lines              ; start of vertical blanking period
DB    256-10,lpixel,4,63
DB    0,0,0,0,0,0,0,0,0,0,0,0

;start vsync (4 lines)           ; vertical sync pulse
DB    256-4,vblank,4,63
DB    0,0,0,0,0,0,0,0,0,0,0,0

;end vsync (1 line)              ; finish vertical sync pulse
DB    256-1,vblank,63,4
DB    0,0,0,0,0,0,0,0,0,0,0,0

;black for 30 lines
DB    256-30,lpixel,4,63         ; rest of vertical blanking period
DB    0,0,0,0,0,0,0,0,0,0,0,0

;blank for 6 lines               ; top margin with reload to satart again
DB    256-6,reload+lpixel,63,0
DB    0,0,0,0,0,0,0,0,0,0,0,0

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: How to begin assembly on Enterprise
« Reply #46 on: 2014.October.08. 17:25:41 »
Quote from: ssr86
What is the role of left/right margin in the sync lines?
It determines where the VSYNC begins and ends within a line. When the video mode for a line is 0, then borders are blank (always black, regardless of the border color), and the active area is VSYNC (negative level relative to black). Without interlace, it should start at the beginning of a line, and the standard length is 2.5 lines, although it is not a problem if it is slightly longer. There are normally 3 blank lines before the VSYNC, and also a few after it. The additional black lines in the EXOS manual are the rest of the vertical retrace period, this area is also what TV broadcast uses for teletext.

For comparison, Commodore machines use 3 vblank + 3 vsync + 3 vblank + 9 additional black lines (18 total).

In the case of the NICK chip, a VBLANK line (mode 0 and all border) is slightly different from a normal fully black line, as it does not output the burst signal before the visible area of the line.

For centering the picture on the screen, it may be useful to know that the horizontal center position for the margins is 31 in theory (and on ep128emu), but on a real machine with a TV this is typically slightly to the left (by up to a whole character), so when the number of columns is odd, it is best to round the margins (31 +/- width/2) up, rather than down. On the emulator, 288 lines are displayed out of 312 total, and the bottom of the visible area is aligned so that it ends 3 lines (i.e. the same as the recommended number of initial blank lines) before VSYNC. On a real TV, it is normally centered similarly (maybe moved up slightly by 1-2 lines), but with at least a few percents of overscan, so fewer lines are visible.

In the LPBs where a margin is 63, it means that the margin is never reached. NICK counts the character position within a line from 0 to 56, and when it is equal to the left or right margin, the display becomes active or border colored, respectively, otherwise its state does not change. Changing a margin from or to 0 at the beginning of an LPB may be missed for one line, because the margin values are read later from the LPB than position 0.

Offline ssr86

  • EP user
  • *
  • Posts: 355
  • Country: pl
Re: How to begin assembly on Enterprise
« Reply #47 on: 2015.May.17. 15:53:43 »
Until now I have loaded all my code with the ep128emu debugger and had to do it twice for my programs to run. I'm assembling to com files with the "new application program" header type (?). Because of the memory layout I use, my code is scattered over more than 47kb of memory. I can't load the com files from basic. My code is not exos compatible.:oops: 
How should I load my programs?
Should I have the com file just be a loader for the "real" code? (I think most games have a small com and at least one prg file...)
Could someone explain how this should be done properly?:oops:
 

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: How to begin assembly on Enterprise
« Reply #48 on: 2015.May.17. 18:46:39 »
Should I have the com file just be a loader for the "real" code? (I think most games have a small com and at least one prg file...)
Could someone explain how this should be done properly?:oops:

Yes, using a small .com file and a large .prg file is a common solution.

Alternatively, if not using multiple files is important, you can increase the size of the .com file up to about 63 KB, and then use epcompress to reduce it to the standard maximum of 47.75 KB or below so that EXOS can load it. The -m3 algorithm is the least efficient compression, but it should be good enough for this purpose, and it is the fastest to unpack and has the lowest memory usage, so it leaves the most space for the program.

Another, more complicated single file solution is to append an EXOS end of file header and then the contents of the .prg at the end of the .com file, and then the loader should open the file again, skip the initial (.com + EOF) part of the file, and load the .prg data that can be of any size. However, this does not work well on tape (the user would have to rewind), and renaming the file would break the loader.
« Last Edit: 2015.May.17. 19:00:44 by IstvanV »

Offline ssr86

  • EP user
  • *
  • Posts: 355
  • Country: pl
Re: How to begin assembly on Enterprise
« Reply #49 on: 2015.May.17. 19:17:12 »
Yes, using a small .com file and a large .prg file is a common solution.
How do I write a loader?:oops:

Alternatively, if not using multiple files is important, you can increase the size of the .com file up to about 63 KB, and then use epcompress to reduce it to the standard maximum of 47.75 KB or below so that EXOS can load it. The -m3 algorithm is the least efficient compression, but it should be good enough for this purpose, and it is the fastest to unpack and has the lowest memory usage, so it leaves the most space for the program.

For instance, the margin examples I've posted a while back. They have code in $0100-$0800, but the screens start at $8000 and $c000, then the LPT is placed in $f000-$f94f, so it won't run from basic (and in through debugger I have to initially load it twice to the memory). If I wanted to keep this layout I would have to compress the gfx, keep the lpt in another place in memory and later unpack the gfx and copy the lpt where I wanted it to be, right (or just skip compression and just copy the data from lower memory to where I want...)?:oops:
 

Offline geco

  • EP addict
  • *
  • Posts: 7081
  • Country: hu
    • Támogató Támogató
Re: How to begin assembly on Enterprise
« Reply #50 on: 2015.May.18. 09:18:01 »
How do I write a loader?:oops:
Here is a small loader example:
Code: [Select]
       macro exos n
                rst   030h
                defb  n
        endm

        org     00f0h
        db    00,05
        dw    fillen
        db    00,00,00,00,00,00,00,00,00,00,00,00

startpr ld     sp,0100h
        ld      a,0ffh
        out     (0b2h),a ;system segment to page2
        ld      hl,error
        ld      (0bff8h),hl ;store soft reset in EXOS segment

        call    seg                 ;ask a free segment from EXOS
        out     (0b3h),a
        xor     a ;open channel 0, and load file header of prg
        ld      de,prg  
        exos    1  
        jp      nz,error ;jp error if error occured

        ld      de,0c000h                ;load file to 0c000h, length 4000h
        ld      bc,4000h
        exos    6
        jp      nz,error ;jp error if error occured

        xor     a
        exos    3 ;close channel 0

        jp      prgstart

prg    db    8,"data.prg"               ;length of file name, file name

seg     exos 24 ;ask a free 16k page
        jp nz,error ;if not enough memory, then reset
        ld a,c
        ret

error   di ;soft reset routin
        ld      sp,0100h
        ld      a,0ffh
        out     (0b2h),a
        ld      c,40h
        exos    0
        ld      a,01h
        out     (0b3h), a
        ld      a,06h
        jp      0c00dh

fillen  equ $-startpr
« Last Edit: 2015.May.18. 10:49:00 by geco »

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14721
  • Country: hu
    • http://enterprise.iko.hu/
Re: How to begin assembly on Enterprise
« Reply #51 on: 2015.May.18. 10:04:46 »
Code: [Select]
jp      nz,error ;jp hiba if error occuredHungarian label left in the comment :oops:
And it is also recommended after the EXOS 6.

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: How to begin assembly on Enterprise
« Reply #52 on: 2015.May.18. 10:29:42 »
How do I write a loader?:oops:
 
For instance, the margin examples I've posted a while back. They have code in $0100-$0800, but the screens start at $8000 and $c000, then the LPT is placed in $f000-$f94f, so it won't run from basic (and in through debugger I have to initially load it twice to the memory). If I wanted to keep this layout I would have to compress the gfx, keep the lpt in another place in memory and later unpack the gfx and copy the lpt where I wanted it to be, right (or just skip compression and just copy the data from lower memory to where I want...)?:oops:

With compression, you can basically create a self-extracting .com (EXOS 5) file that uses all space from 100h to FFFFh (with the epcompress -m3 method, where all the decompressor code and data is below 100h), as long as the compressed size is valid (<= 47.75 kilobytes) for the EXOS loader. Large unused memory areas that are filled with zeros are compressed to only a few bytes. After the original program is unpacked in memory, it is run as usual starting at 100h.

For larger (> 63.75 KB) or more complex programs, it is best to use a loader and separate .prg file.

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: How to begin assembly on Enterprise
« Reply #53 on: 2015.May.18. 10:33:28 »
Hungarian label left in the comment :oops:

Also, the 'szeg' label has not been renamed to 'seg' where the routine is called.

Offline lgb

  • EP addict
  • *
  • Posts: 3563
  • Country: hu
  • æðsta yfirmaður
    • http://lgb.hu/
Re: How to begin assembly on Enterprise
« Reply #54 on: 2015.May.18. 10:39:38 »
Large unused memory areas that are filled with zeros are compressed to only a few bytes. After the original program is unpacked in memory, it is run as usual starting at 100h.

At the other hand, I always felt, that a decent assembler/linker should provide the BSS area, thus uninitialized data. I am not sure eg sjasm can do this, I usually "allocate" these kind of data with my own macros after the end of the loaded program, and if needed, I fill that area with zeroes at the beginning of the program (so having zero for the value of these locations). I only say this, because I saw many software contain "BSS like" parts at the middle of the program, thus wasting space on the stored program file at least. Okey, with compression is more or less not an issue too much, I think :)

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14721
  • Country: hu
    • http://enterprise.iko.hu/
Re: How to begin assembly on Enterprise
« Reply #55 on: 2015.May.18. 10:50:06 »
When you load games from tape you can hear when loading lot of zeros. I really hate when I hear it for a minutes... :twisted: Ok, from SD card don't problem, just wasting of the storage space :-)

Offline geco

  • EP addict
  • *
  • Posts: 7081
  • Country: hu
    • Támogató Támogató
Re: How to begin assembly on Enterprise
« Reply #56 on: 2015.May.18. 10:50:33 »
Also, the 'szeg' label has not been renamed to 'seg' where the routine is called.

Mistakes have been corrected. This CALL SZEG mistake is interesting, because I typed it after I renamed the label :D

Offline Tuby128

  • EP addict
  • *
  • Posts: 1448
  • Country: hu
Re: How to begin assembly on Enterprise
« Reply #57 on: 2015.May.18. 12:25:43 »
When you load games from tape you can hear when loading lot of zeros. I really hate when I hear it for a minutes... :twisted: Ok, from SD card don't problem, just wasting of the storage space :-)
Can you show me how it's sounds when a lot of zeros loaded from tape?

Offline IstvanV

  • EP addict
  • *
  • Posts: 4822
Re: How to begin assembly on Enterprise
« Reply #58 on: 2015.May.18. 13:46:06 »
Can you show me how it's sounds when a lot of zeros loaded from tape?

A long sequence of zero bytes is a square wave at about 2000 Hz. With FFh bytes instead, it is 3000 Hz. In other words, empty space filled with FFh loads faster from tape than zeros. But it does not matter with compression. In general, anything that sounds like a pure, continuous tone on tape is likely to be a sequence of identical bytes.
« Last Edit: 2015.May.18. 13:56:26 by IstvanV »

Offline Zozosoft

  • Global Moderator
  • EP addict
  • *
  • Posts: 14721
  • Country: hu
    • http://enterprise.iko.hu/
Re: How to begin assembly on Enterprise
« Reply #59 on: 2015.May.18. 14:14:22 »
And the CRC bytes add some rhythm :-)