English Amiga Board


Go Back   English Amiga Board > Coders > Coders. General > Coders. Tutorials

 
 
Thread Tools
Old 14 August 2018, 14:33   #1
spud
Registered User
 
Join Date: May 2010
Location: London, UK
Posts: 268
REQ:ASM Trackloader

Hi all

Are there any good ASM tutorials on how one would take an off the shelf tracker loader (eg, RNC loader?) and use it to write code in the right format to a disk and likewise read it off again? Let's say I have a single file game I want to track load in, what do I have do to that file?

I've seen lots of threads on the forum about coding your own track loader from scratch and they're generally very long (as they're continually developed and improved over the course of the thread) and very technical and my eyes tend to glaze over after a while when trying to understand them. They may be a technical level beyond my capability

Does such a tutorial exist? If not, can it?

Cheers
spud is offline  
Old 14 August 2018, 14:48   #2
WayneK
Registered User
 
Join Date: May 2004
Location: Somewhere secret
Age: 50
Posts: 364
The comments at the top of the RNC loader source tell you exactly how to use it for reading + writing... or if you prefer you could take any of the loaders from flashtro.com (some by them, some reversed from various Amiga games/cracks that were used during 'the glory days') and read the accompanying instructions!

For writing to disk there are various Aminet utils or you could just use AR3 carts 'WT' command (or Asm-One, or... many options).
WayneK is offline  
Old 14 August 2018, 16:25   #3
heavy
noodle
 
Join Date: Jun 2007
Location: europe
Posts: 247
an article by Loïc Far from a french magazine (Amiga News Tech)
http://cyberpingui.free.fr/tuto_trackloader.htm
heavy is offline  
Old 14 August 2018, 21:38   #4
spud
Registered User
 
Join Date: May 2010
Location: London, UK
Posts: 268
Quote:
Originally Posted by WayneK View Post
The comments at the top of the RNC loader source tell you exactly how to use it for reading + writing... or if you prefer you could take any of the loaders from flashtro.com (some by them, some reversed from various Amiga games/cracks that were used during 'the glory days') and read the accompanying instructions!

For writing to disk there are various Aminet utils or you could just use AR3 carts 'WT' command (or Asm-One, or... many options).
You make it sound so simple I'll have a look at flashtro and also look at the article Heavy has provided a link to.

Many thanks both Expect more questions later...
spud is offline  
Old 14 August 2018, 22:01   #5
heavy
noodle
 
Join Date: Jun 2007
Location: europe
Posts: 247
Quote:
Originally Posted by spud View Post
Let's say I have a single file game I want to track load in, what do I have do to that file?
easy way
use a tool like SectorTrasher (The Master/Silents Dk): Zoned
pick the file, "write sectors"
and then set the load address and the jump address, the same most of the time : if program packed at absolute address (ex. $40000), use this one, else make sure the program is relocatable or (re)pack it at absolute address you want.
and "write bootblock"

and voilà

if you want to code : copy the file (AR, sectortrasher,megamon,etc...)
use the trackdisk.device directly from boot
Code:
   
 dc.b	"DOS",0
 dc.l	0
 dc.l	$370

    movea.l    $4.w,a6
    move.l    #80*512,36(a1)    ; len nb sectors*512 (80)
    move.l    #$40000,40(a1)    ; buffer
    move.l    #11*512,44(a1)    ; offset sector start (11)
    move.w    #2,28(a1)        ; read
    jsr    -456(a6)        ;
    move.w    #9,28(a1)        ; td_motor
    clr.l    36(a1)        ; off
    jsr    -456(a6)        ;
    
    jmp    $40000
compil, fix the checksum and write at sector 0 (with AR, megamon, or other tool for boot)
heavy is offline  
Old 14 August 2018, 22:51   #6
StingRay
move.l #$c0ff33,throat
 
StingRay's Avatar
 
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
Quote:
Originally Posted by spud View Post
Let's say I have a single file game I want to track load in, what do I have do to that file?

WayneK has given a lot of good tips already so I'll only add that for a simple single file game you could use trackdisk.device and load the game using DoIO from the bootblock. No hardware trackloader needed at all. The only thing you need to take care of is the load address, if it is very low in memory you'll first have to load to a "safe" location, kill the system (DMA, interrupts off etc.) and copy the binary to real location then.
StingRay is offline  
Old 15 August 2018, 15:13   #7
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by StingRay View Post
you could use trackdisk.device and load the game using DoIO from the bootblock. No hardware trackloader needed at all.

This also has the advantage of working when booting off any floppy drive on kickstart 2.0+ without worrying about which drive it is.
hooverphonique is offline  
Old 15 August 2018, 19:36   #8
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
To make it a real tutorial, here is a more general example, which can automatically create a working ADF from a script or a Makefile.

It is advisable to make an assembler source, which defines the contents of your whole disk image, including the boot block and the track-loader code, as well as your main program to load, which is inserted at sector-borders with INCBIN.

diskimage.asm:
Code:
        include "exec/io.i"
        include "devices/trackdisk.i"

; exec.library LVOs
DoIO            equ     -456

; program base address
LOAD_ADDR       equ     $70000


        org     0                       ; don't care, all code is PC-relative


boot:
        dc.b    "DOS",0
        dc.l    0                       ; checksum will be inserted here
        dc.l    880                     ; not used

;---------------------------------------------------------------------------
boot_code:
; a6 = SysBase
; a1 = trackdisk IoStdReq

        move.l  a1,a5                   ; a5 IoStdReq
        lea     LOAD_ADDR,a2            ; a2 program load address

        ; load binary program at LOAD_ADDR into memory
        move.l  #prog_end-prog,IO_LENGTH(a1)
        move.l  a2,IO_DATA(a1)
        move.l  #prog-boot,IO_OFFSET(a1)
        jsr     DoIO(a6)

        ; motor off
        move.l  a5,a1
        move.w  #TD_MOTOR,IO_COMMAND(a1)
        clr.l   IO_LENGTH(a1)
        jsr     DoIO(a6)

        jmp     (a2)


;---------------------------------------------------------------------------
        rorg    2*TD_SECTOR

prog:
        incbin  "test.bin"
        cnop    0,TD_SECTOR
prog_end:
test.bin is the main program in raw binary format, to be loaded at LOAD_ADDR ($70000 in this example).

ORG is used to tell the assembler it is an absolute, raw binary file. For your test.asm code you would write "ORG $70000" on top of the source. Check your assembler's manual how to output raw binary files (for vasm it is the -Fbin option).

The second part is a small utility, which creates a full 880K disk image from the binary file above. It extends the image to 880K, filling the unused sectors with zero and calculates the boot block checksum. The resulting ADF can be directly tested with an emulator or written to a disk.

I am using a small, portable, C program for this task (makeimage.c):
Code:
/*
 * Makes a disk image of 901120 (0xdc000) bytes.
 * Calculates boot block checksum.
 */

#include <stdio.h>
#include <string.h>
#include <stdint.h>

#define DISKSIZE (0xdc000)

uint8_t image[DISKSIZE];


static void boot_chksum(uint8_t *p)
{
  uint32_t oldchk,chk=0;
  int i;

  memset(p+4,0,4);
  for (i=0; i<1024; i+=4) {
    oldchk = chk;
    chk += ((uint32_t)p[i+0] << 24) | ((uint32_t)p[i+1] << 16) |
           ((uint32_t)p[i+2] << 8) | p[i+3];
    if (chk < oldchk)
      ++chk;  /* carry */
  }

  chk = ~chk;
  p[4] = (uint8_t)((chk >> 24) & 0xff);
  p[5] = (uint8_t)((chk >> 16) & 0xff);
  p[6] = (uint8_t)((chk >> 8) & 0xff);
  p[7] = (uint8_t)(chk & 0xff);
}


int main(int argc,char *argv[])
{
  FILE *f;
  int rc = 1;
  size_t len;

  if (argc == 2) {
    if (f = fopen(argv[1],"rb")) {
      len = fread(image,1,DISKSIZE,f);
      if (len > 0) {
        if (len < DISKSIZE)
          memset(image+len,0,DISKSIZE-len);
        boot_chksum(image);
        fwrite(image,1,DISKSIZE,stdout);
        rc = 0;
      }
      else
        fprintf(stderr,"Image read error!\n");
    }
    else
      fprintf(stderr,"Cannot open '%s'!\n",argv[0]);  
  }
  else
    fprintf(stderr,"Usage: %s <image data>\n",argv[0]);

  return rc;
}
Generate the ADF with:
Code:
makeimage diskimage > test.adf
EDIT: Note, that trackdisk.device TD_READ can only load into Chip-RAM, until OS2.0!

Last edited by phx; 15 August 2018 at 19:43. Reason: Note on TD_READ
phx is offline  
Old 15 August 2018, 19:52   #9
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
There is something I am unsure about myself: Usually the data cache should not be enabled, when the OS executes the boot block code. But I seem to remember that there are some strange 68060-boards for the A1200 which boot with a full MMU setup and data caches enabled (probably by Phase5 68060.library or ppc.library in ROM?).

So you might want to flush the caches, after track-loading your program into Fast RAM.
phx is offline  
Old 16 August 2018, 11:11   #10
spud
Registered User
 
Join Date: May 2010
Location: London, UK
Posts: 268
All sorts of awesome to read through and digest. Many thanks for all who have contributed to this request!
spud is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
[REQ:ASM] Reading a keystroke jman Coders. Tutorials 34 17 August 2023 12:36
[REQ:ASM] Sprite collisions basics jman Coders. Tutorials 5 03 September 2011 00:07
[REQ:ASM] Assembling and running jman Coders. Tutorials 9 07 May 2011 18:39
REQ:ASM getting elapsed time on A1200 jman Coders. Tutorials 18 11 January 2011 22:24
REQ:ASM How to use buffers jman Coders. Tutorials 7 01 December 2010 01:41

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 00:29.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11670 seconds with 15 queries