19 March 2017, 20:54 | #1 |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,099
|
Trackmo tech
In my quest to be able to compete with the brightest minds of '87, I figured being able to create a trackmo was on the required list.
Before you grab your pitchforks let me make it clear that: 1) This is purely a learning exercise, I derive enjoyment from discovering how things work 2) If I ever create something worthwhile a HD-compatible version will be available alongside 3) I'll probably use somebody else's track loading routines once I understand how they are supposed to work I've gotten pretty far on my own with the usual resources (HRM, this forum and Photons site) and am at a point where I can take over the system from a boot block and load from the disk. The loaded binary is just a simple self-checking program with lots of repeated data (~384k) that I used to debug the track loader. It seems to work fine in WinUAE in all the various configurations I bothered checking (except kick13+OCS+8MB chip, but that seems to be causing me trouble with other programs as well, so I haven't looked into that yet). With that out of the way, my questions! Killing the system. Following these steps am I doing something wrong/suboptimal? (it'd be nice if this worked on all Amigas, but my target is classic A500 (with support for common expansions) or thereabouts: 1) Kill any caches with CacheControl(0, -1) if exec.library v37 or later 2) Scan SysBase->MemList for the largest MEMF_FAST block (if available) - here it seems I need to round mh_lower/mh_upper in some way to get the full memory? 3) Use SysBase->MaxLocMem as end of chip mem 4) Now I need to determine where we can relocate ourselves to and find a safe place to put the stacks (user/supervisor). This is a bit iffy since we could be loaded anywhere - what's the most compatible strategy here (that's easy to implement)? I currently go for the top of fast ram (if available) otherwise top of chip. 4) In a Supervisor()-call I take over the system by disabling interrupts/dma, moving vbr to 0 (if 68010+) and switch stacks. 5) I now copy the rest of the boot loader to the new location and jump there. Track loading. I don't expect anybody else to subject their poor Amigas to my track loading code (and unfortunately I don't have a real one to test on at the moment), so I'm a restricted in how well I can test compatibility, so I'd appreciate some input on how I can avoid the usual pitfalls and ensure a better chance of actually running on the real hardware. In another thread Toni Wilen mentions that waiting a little while before virtually inserting the disk in WinUAE slightly alters the timing - more tips like this would be great. For timing I take a cue from Photon's example source (http://coppershade.org/asmskool/SOUR...%23MFMloader.S) and use vhposr for timing - That should be OK? Stepping in the same direction requires 3ms of waiting - easy enough, but HRM mentions DSKSTEP needing to be pulsed, Photon's source does two NOPs between toggling the bits - is this the preferred method? I read vhposr figuring that should work even with an accelerator, is this better/worse? HRM states that 15ms is needed after a direction change - this is from the last step pulse? Writing this I'm beginning to suspect my code may only work by accident (would a violation be detectable in WinUAE?) If I got the code for reading the TOD counter in CIAA right I'm able to load 769 sectors in 843 vblanks (~17s) giving a transfer speed of about 23k/s. I couldn't find much in the way of hard numbers for what kind of speeds to expect, but since I don't think I'll be going for overlapping DMA and MFM decoding in a boot block, there probably won't be any record broken, but it'd be nice to know if it's acceptable compared to other loaders. For a trackmo I envision having some disk loader code potentially running every vblank for simplicity rather than going for max disk throughput, so max speed is only of theoretical interest. Phew, that turned out a lot longer than I expected. Thanks to those who bothered reading even part of it TL;DR: how2kill system but keep its brain/when do I need to wait 15ms for a floppy direction change/what are the normal loading speeds from floppy? Last edited by paraj; 19 March 2017 at 22:15. Reason: Critical 68010+ bug fixed (wrong exception frame used) - Oops! |
20 March 2017, 18:45 | #2 |
Registered User
Join Date: Oct 2013
Location: Hamburg
Posts: 69
|
In case you haven't seen it, the sources of Planet Rocklobster include the trackmo framework and build tools. The track loading routines are based Photon's work as well.
A lot of stuff is happening early in the bootblock, e.g. just querying and then allocating the largest chip/fast block, then setting up a custom memory management on top of that and use that for the stack allocation, the where-to-load-ourselves region etc. The VBR is used as-is, not set to 0. CacheControl is invoked later, like you described. Supervisor() is only used when resetting. |
20 March 2017, 20:07 | #3 | |
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,099
|
Quote:
Thanks for the pointer! The boot loader code looks familiar, I think I may have stumbled on it (or a variation) while searching for info on amiga boot loaders... It may have been the same link actually, but I was probably too focused on the task at hand to notice. As far as I can tell their loader is pretty system friendly - allocating the correct way and not overwriting any memory used by the system, so they wouldn't need to re-locate the VBR. Instead it seems they rely on VBR always being zero to save a couple of instructions (they have commented out code to read it). Doesn't seem like a totally unreasonable assumption (and they probably checked most popular kickstart versions), so I'll keep that in mind when I need to shave off a few bytes |
|
30 March 2017, 19:49 | #4 | |||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
Maybe determining the CPU type could be useful. This is usually the first I do, before reading VBR, touching the caches or initialize the MMU. Be prepared for really strange 68060 boards. Last year I had a tester with A1200/060 where Sqrxz4 hung in the boot-loader. It turned out that VBR was NOT zero (during boot!) and that the MMU already had a full configuration, which I had to disable and replace by a simple transparent translation setting (for Chip-RAM/Fast-RAM, ignoring Zorro space). I have a A3000 and A4000 with CSPPC/060 myself. But I have never seen that before! Quote:
Code:
vlink -brawseg -q -minalign 2 -Tgame.ld -o sqrxz4raw main.o interrupt.o game.o tiles.o map.o bob.o blit.o hero.o monster.o animation.o platform.o crate.o text.o scroll.o txtscroll.o statusbar.o logo.o font.o background.o display.o input.o music.o sound.o story.o menu.o ptplayer.o trackdisk.o hiscores.o memory.o debug.o end.o Devel:games/Sqrxz4OCS> list sqrxz4raw#? sqrxz4raw.fast.relfast 500 ----rwed Today 19:13:43 sqrxz4raw.fast.relchip 1408 ----rwed Today 19:13:43 sqrxz4raw.fast 116796 ----rwed Today 19:13:43 sqrxz4raw.chip 399932 ----rwed Today 19:13:43 sqrxz4raw 63 ----rwed Today 19:13:43 Code:
PHDRS { fast PT_LOAD; chip PT_LOAD; } SECTIONS { . = 0; .chip: { *(chipmem) . = ALIGN(2); _FREECHIP = .; } :chip . = 0x100000; .text: { *(CODE) } :fast .data: { *(DATA) } .sdata: { _LinkerDB = . + 0x7ffe; _SDA_BASE_ = . + 0x7ffe; *(.sdata __MERGED) } .bss: { *(BSS) } } Quote:
Quote:
Quote:
I just start reading a track, wait for DMA to finish, then decode the blocks I need. Last edited by phx; 30 March 2017 at 20:00. Reason: Remove '.' between "No" and "VPOS-based". |
|||||
30 March 2017, 20:57 | #5 | ||||
Registered User
Join Date: Feb 2017
Location: Denmark
Posts: 1,099
|
Quote:
Quote:
Quote:
I've been playing around with various approaches on my own and ended up with exactly this approach, just using my own hacky hunk->files converter. Nice that vlink supports this directly! Guess I should have read the manual, but since this is a hobby project I prefer just playing around with some code EDIT: My concern about where to put the stacks is that I'm starting to use absolute memory addresses before relocating - I could potentially be overwriting where we're running (even if the probability is remote) Quote:
|
||||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Tech AMIGA magazine | thinlega | request.Apps | 9 | 19 February 2021 17:26 |
LN2 tech demo | gimbal | project.Amiga Game Factory | 63 | 02 October 2008 20:22 |
The 50 Best Tech Products of All Time | rbelk | Retrogaming General Discussion | 19 | 04 April 2007 18:25 |
help with Tech running in WinUAE | redblade | support.Games | 9 | 17 April 2004 02:26 |
|
|