Tuesday, April 12, 2016

Creating a Hard Drive Image For Emulator Use

Recently we found a bug where the game would crash when a user would boot to a hard drive before launching the game off of a floppy. We recreated this situation by using an AppleWIN hard drive image that booted to ProDOS Basic and then executing a ProDOS command from there to boot from the floppy drive.

Below are instructions on how to set this up and some challenges we ran into during that process. The instructions assume a basic understanding of the Windows Command Prompt, CiderPress, AppleWIN, and Copy II Plus. I’m happy elaborate on any steps involving use of this software, just ask.

When AppleWIN is setup with a hard drive it will only attempt to boot from the hard drive. In this scenario it is necessary to type a ProDOS command, after the hard drive is booted, if you want the machine to load an image on the floppy drive.  Keep in mind the command prompt is identical for both ProDOS and AppleSoft. The following ProDOS command will attempt a boot from a floppy disk drive in slot 6:

] PR#6

So, we found an interesting chicken-and-egg paradox in this process: booting an unformatted hard disk will result in a crash.

How do we load a utility to format a hard disk for the first time if AppleWIN automatically tries to boot from the hard disk once the hard disk is enabled? Hint: It’s not an AppleWIN setting. 

The answer is found below.

1. Create a 0 byte file using a Windows PC.
  • Launch the command prompt with admin privileges
    • Click Start and type cmd in the search box
    • Press CTRL+Shift+Enter 
    • A command prompt with admin privileges enabled will open 
  • Create a 0 byte file in c:\applwin using the following syntax
    • In Win7 - fsutil file createnew c:\applewin\applehdd.hdv 0
    • Previous versions of Windows can use debug instead of fsutil to create the file

2. Use CiderPress to choose any random Windows file to add to applehdd.hdv
  • This step prevents Windows from deleting the 0 byte file when it is accessed by an application
  • It doesn’t matter what file type is added as all contents of the hard drive will be erased when it is formatted. I chose a text file

3. Enable the Hard Drive in AppleWIN
  • Enter AppleWIN configuration
  • Click on the Disk tab
  • Check the box next to Enable Hard Disk
  • Choose the applehdd.hdv file in c:\applewin
  • AppleWIN will pop up a window saying it needs to restart. Proceed with the restart. 

4. Boot Copy II Plus version 8.2
  • Other versions of Copy II Plus may work. This is just the version I used
    • Note that Copy II Plus 9.1 requires the model in AppleWIN's configuration to be set to enhanced Apple IIe
  • Insert the Copy II Plus 8.2 floppy disk in drive 1
  • Click the boot button in AppleWIN using the Apple icon
  • You should see the Apple monitor prompt (an asterisk with a bunch of hex numbers)
    • This is because once a hard disk is enabled, AppleWIN will try to boot from the hard disk first. Since the hard disk isn’t formatted, the boot process crashes.
  • Boot from the floppy after crashing
    • Type C600G at the Apple monitor prompt. 
      • This will execute the machine instructions stored in ROM for the boot0 process 
      • AppleWIN attempts to boot the floppy disk in drive 1 at this point

5. Format Hard Disk
  • Once Copy II Plus has launched, format the hard disk for ProDOS 
    • Use Format menu option. Pretty much just follow the prompts
    • The hard disk is slot 7, drive 1

6. Copy ProDOS onto Hard Disk
  • If you're copy of ProDOS is stored on a .SHK file you'll need to transfer it to a disk image. If ProDOS is already on a disk image, skip ahead to the "Insert the ProDOS disk image" step below.
    • To transfer ProDOS from a .SHK file to a disk image, start by using CiderPress to extract the file
      • Select Keep Apple II Formats
    • Create a blank disk image with CiderPress
    • Add the extracted file to the disk image
  • Insert the ProDOS disk image into the floppy drive. (I used ProDOS 2.03)
  • Copy the file from the ProDOS disk image in drive 1 to the hard disk

7. Copy ProDOS Basic onto Hard Disk
  • Insert any disk image that contains the ProDOS file BASIC.SYSTEM into floppy drive 1. Copy II Plus 9.1 contains this file and is what I used. 
  • Copy the file BASIC.SYSTEM from drive 1 to the hard disk
  • All done! 
    • Clicking the boot button on AppleWIN should now result in the hard disk booting to the ProDOS basic prompt ]
  • From the ProDOS Basic prompt, launch floppy disks by typing PR#6 
  • Create folders using the Copy II Plus 9.1 menu option Create Subdirectories

*All versions of ProDOS after 1.9 required an Enhanced Apple IIe. AppleWIN configuration options can be set to run the emulator in Enhanced Apple IIe mode.

Tuesday, April 5, 2016

New Feature: Fields of Green

Across the landscape of the world in Nox Archaist both short and tall grass can be found in abundance. Tall grass hides the lower half of mob icons and player icons from view.

The player and mobs think they are pretty clever (the player is probably right). When standing in tall grass they go into stealth mode and stop waving their weapons around.

Tech Talk:

For Review
  • Each tile graphics has a unique ID number. 

New Concepts
  • Each tile is 14 pixels wide x 16 pixels. (in assembly language terminology, 2 screen bytes x 16 lines) 
The tech topic for this post is drawing tiles.

Each tile in the game has it's own shape table which stores the hexadecimal data used by the Apple II hardware to turn on the pixels on the hi-res graphics screen. The shape tables are stored on disk and loaded into auxiliary memory when the game boots. 

There is a subroutine called DRAW.TILE at the core of graphics engine which will draw any shape table at any location on the view screen's tile grid (currently !17 tiles wide X !11 tiles deep). The tile grid location and the shape table to use are passed as parameters.

Since the shape tables are 14x16, as noted above, DRAW.TILE is designed to draw 14x16 shapes. It does this using a loop. Like all loops, it has a stop value that triggers the end of the loop.
How does this relate to tall grass and the lower half of the tile being hidden? 
If the player is standing on a map location with the tile ID for tall grass, a parameter is passed to DRAW.TILE which tells the routine to use a different stop value, thus triggering an end to the loop after only the top half of the shape is drawn.

Friday, April 1, 2016

Horsing Around (New Feature)

I am noticing more and more that game glitches can be a good source of ideas for cool features. As mentioned in earlier posts, by default the player can walk on any terrain and a collision check subroutine is the code that marks certain terrain as blocked.

During collision control testing the horse was unexpectedly able to traverse river tiles.

I was about to fix it, and then thought that allowing horses to jump over rivers, well, just make plain horse sense.