subbios

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Subbios provides all commands to control the Nimbus. It's similar (but different) to the original RM Nimbus SUBBIOS but has the advantage that you don't need to write assembler!

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FGetCltContents

func FGetCltContents(t *TGraphicsOutput) (clt []int)

FGetCltContents returns the entire colour lookup table.

Types

type Stdio

type Stdio struct {
	SuppressCtrlCInterrupt               bool // Set to true to prevent CTRL-C keyboard interrupts breaking input/output (you can still check the status though).
	SuppressCtrlShiftScrollLockInterrupt bool // Set to true to prevent CTRL-SHIFT-SCROLL LOCK keyboard interrupts  breaking input/output (you can still check the status though).
	// contains filtered or unexported fields
}

Stdio implements all the console commands in kind-of old-skool C stylee.

func (*Stdio) GetCtrlCInterrupt

func (sio *Stdio) GetCtrlCInterrupt(unsetAfterChecking bool) bool

GetCtrlCInterrupt checks if a CTRL+C interrupt flag is set. Passing true will unset the flag after checking, otherwise the flag remains unchanged.

func (*Stdio) GetCtrlShiftScrollLockInterrupt

func (sio *Stdio) GetCtrlShiftScrollLockInterrupt(unsetAfterChecking bool) bool

GetCtrlShiftScrollLockInterrupt checks if the CTRL+SHIFT+SCROLL LOCK interrupt flag is set. Passing true will unset the flag after checking, otherwise the flag remains unchanged.

func (*Stdio) GetCurpos

func (sio *Stdio) GetCurpos() (row, col int)

GetCurpos returns the current cursor position and is a bit of cheat really but nvm.

func (*Stdio) Getch

func (sio *Stdio) Getch() (r rune)

Getch gets a rune from keyboard input buffer or returns 0 if the buffer is empty.

func (*Stdio) Getchar

func (sio *Stdio) Getchar() (r rune)

Getchar gets a rune from keyboard input buffer without waiting for ENTER to be pressed. Stdio.KeyboardBufferFlush() should be called first though!

func (*Stdio) KeyboardBufferFlush

func (sio *Stdio) KeyboardBufferFlush()

KeyboardBufferFlush removes all chars from the keyboard input buffer. It should be called before Scanf() or Getchar().

func (*Stdio) Printf

func (sio *Stdio) Printf(st string)

Printf imitates C's printf command but does not support formatting strings - this should be done by Go itself using fmt.sprintf() or similar. The escape chars for newline `\n` and `\t` tab are supported. ANSI escape sequences can also be sent with this function - [a complete description of supported escape sequences and their effects is given below](#escape-sequences).

func (*Stdio) Putchar

func (sio *Stdio) Putchar(r rune)

Putchar prints a single rune to the screen.

func (*Stdio) Putchars

func (sio *Stdio) Putchars(runes []rune)

Putchars prints a slice of runes to the screen.

func (*Stdio) Scanf

func (sio *Stdio) Scanf(textBuffer *[]rune)

Scanf is a little bit different to the usual Scanf. A buffer of runes (which can be empty but not nil) is passed to the function and echoed into the scrolling area from the current cursor position. The user can then edit the buffer as they please and the changes returned via the buffer's pointer when they hit ENTER.

type Subbios

type Subbios struct {
	Monitor *ebiten.Image

	FunctionStatus  int
	FunctionError   int
	THardSums       THardSums
	TGraphicsOutput TGraphicsOutput
	TRawConsole     tRawConsole
	TGraphicsInput  TGraphicsInput
	Stdio           Stdio
	// contains filtered or unexported fields
}

The subbios commands are grouped by Type as represented by this struct.

func (*Subbios) Boot

func (s *Subbios) Boot()

Boot simulates the RM Nimbus "Welcome" boot screen and operating system loading workflow. The original Nimbus would also display system info, such as firmware version, serial number, memory, etc. Nimgobus immitates this using the Go compiler version as the firmware version, and displays the actual physical and virtual memory size. Serial number is a string constant as is the serial number of the Nimbus that provided the ROM dump for the emulation on MAME, from which various bits and pieces were reversed engineering for nimgobus.

func (*Subbios) Init

func (s *Subbios) Init()

Initializes the subbios commands.

func (*Subbios) Update

func (s *Subbios) Update()

Update needs to be called on each Ebiten update, ideally by Nimbus.Update()

type TGraphicsInput

type TGraphicsInput struct {
	// contains filtered or unexported fields
}

TGraphicsInput implements the one surviving function of t_graphics_input.

func (*TGraphicsInput) FEnquirePositionAndButtonStatus

func (t *TGraphicsInput) FEnquirePositionAndButtonStatus() (x, y, b int)

FEnquirePositionAndButtonStatus returns the x, y position of the mouse and the button status. Unlike in the original Nimbus the mouse position is always being monitored and does not need to be initialized. There is also no support for resetting the origin or scale, since nimgobus applications run in Windowed environments and this would be really weird to implement and use. Instead, the x, y positions are simply scaled down and reported relative to the nimgobus screen co-ordinates.

type TGraphicsOutput

type TGraphicsOutput struct {
	On bool
	// contains filtered or unexported fields
}

TGraphicsOutput has all the t_graphics_output functions attached to it.

func (*TGraphicsOutput) FArcOfEllipse

func (t *TGraphicsOutput) FArcOfEllipse()

FArcOfEllipse is not implemented

func (*TGraphicsOutput) FCopyAreaPixel

func (t *TGraphicsOutput) FCopyAreaPixel()

FCopyAreaPixel was not implemented because it's redundant in nimgobus - just use FReadAreaPixel followed by FWriteAreaPixel instead.

func (*TGraphicsOutput) FCopyAreaWord

func (t *TGraphicsOutput) FCopyAreaWord()

FCopyAreaWord is not implemented because it's redundant in nimgobus.

func (*TGraphicsOutput) FDrawSprite

func (t *TGraphicsOutput) FDrawSprite(s sprite.Sprite, saveTable *sprite.SaveTable, x, y, pose int, xor bool, clippingAreaId int)

FDrawSprite draws a sprite on the screen and stores the overwritten data in an saveTable array.

func (*TGraphicsOutput) FEraseSprite

func (t *TGraphicsOutput) FEraseSprite(saveTable *sprite.SaveTable)

FEraseSprite erases a sprite associated with a saveTable. Unlike in the original implementation, it is only necessary to pass the sprite and saveTable as arguments.

func (*TGraphicsOutput) FFillArea

func (t *TGraphicsOutput) FFillArea(fillStyle, fillStyleIndex, fillColour1, fillColour2, transparency int, geometricData []int)

FFillArea fills the area described by a set of vertices given in the geometricData parameter. fillStyle: 0 - hollow, 1 - solid using fillColour1, 2 - solid using dither, 3 - solid using hatched pattern. fillStyleIndex (fillStyle=0, 1) - ignored. fillStyleIndex (fillStyle=2) - dither pattern to use. fillStyleIndex (fillStyle=3) - hatching pattern to use. fillColour1 - the first fill colour fillColour2 - the second fill colour (ignored unless hatching selected). transparency - fillColour2 is transparent if set to 1 in hatching mode. XOR mode can be selected by passing 256 in fillColour1 when using a dither pattern, or by adding 256 to fillColour1's value if otherwise. geometricData... TODO: use [][2]int{} for geometricData

func (*TGraphicsOutput) FFloodFillArea

func (t *TGraphicsOutput) FFloodFillArea(fillStyle, fillStyleIndex, fillColour1, fillColour2, transparency, boundarySpecification, colourOfBoundary, x, y int)

FFloodFillArea fills the screen out from the point (x, y) to a boundary. fillStyle: 0 or 1 - solid using fillColour1, 2 - solid using dither, 3 - solid using hatched pattern. fillStyleIndex (fillStyle=0, 1) - ignored. fillStyleIndex (fillStyle=2) - dither pattern to use. fillStyleIndex (fillStyle=3) - hatching pattern to use. fillColour1 - the first fill colour. fillColour2 - the second fill colour (ignored unless hatching selected). transparency - of fillColour2. boundarySpecification: 0 - any colour different from that of the seed position is a boundary, 1 - the boundary is any pixel of colour colourOfBoundary. colourOfBoundary - the colour of the boundary (ignored if boundarySpecification == 0). x - x-coordinate of the seed position. y - y-coordinate of the seed position.

func (*TGraphicsOutput) FGetBorderColour

func (t *TGraphicsOutput) FGetBorderColour() int

FGetBorder returns the current border colour.

func (*TGraphicsOutput) FGetCltElement

func (t *TGraphicsOutput) FGetCltElement(elementNumber int) (firstPhysicalColour, flashSpeed, secondPhysicalColour int)

FGetCltElement returns an element from the colour lookup table. elementNumber can be in the range 0-15 for low-resolution mode, or 0-3 in high-resolution mode. If any parameters are out of range, the error EInvalidParameter is given. See FSetCltElement for a description of the return values.

func (*TGraphicsOutput) FGetCurrentOutputClippingArea

func (t *TGraphicsOutput) FGetCurrentOutputClippingArea() (id int)

FGetCurrentOutputClippingArea gets the current clipping area.

func (*TGraphicsOutput) FGetDisplayLine

func (t *TGraphicsOutput) FGetDisplayLine()

FGetDisplayLine is not implemented as it's redundant in nimgobus.

func (*TGraphicsOutput) FGetDitherPattern

func (t *TGraphicsOutput) FGetDitherPattern(ditherId int) (ditherPattern [4][4]int)

FGetDitherPattern returns a dither pattern.

func (*TGraphicsOutput) FGetHatchingPattern

func (t *TGraphicsOutput) FGetHatchingPattern(hatchingId int) (hatchingPattern [16][16]int)

FGetHatchingPattern returns a hatching pattern.

func (*TGraphicsOutput) FGetOutputClippingAreaLimits

func (t *TGraphicsOutput) FGetOutputClippingAreaLimits(id int) (minX, minY, maxX, maxY int)

FGetOutputClippingAreaLimits returns the limits of a clipping area. id is the clipping area id (range: 1 - 9 (0 is not user-definable)) If id is out-of-range we get EInvalidParameter. Returns the min x, min y, max x and max y co-ordinates of the clipping area boundary.

func (*TGraphicsOutput) FGraphicsOutputColdStart

func (t *TGraphicsOutput) FGraphicsOutputColdStart()

FGraphicsOutputColdStart initializes the graphics system. If the graphics system is not initialized with either cold start or warm start then the other graphics functions will return the error ENotInitialized (except the colour lookup table and border colour functions). If the error EAlreadyOn is returned it may be useful to call function 4 (reinitialize) to restore the screen to a known starting point. WARNING - all of the internals of the graphics system are reinitialized whenever the the screen width is changed, even when graphics are switched off. On the Nimbus it was very important to switch off the graphics system before exiting (FGraphicsOutputOff) before exiting - not so important here, but it's implemented nonetheless.

func (*TGraphicsOutput) FGraphicsOutputOff

func (t *TGraphicsOutput) FGraphicsOutputOff()

FGraphicsOutputOff closes down the graphics system, which means that any future access to TGraphicsOutput results in the error ENotInitialized (exceptions are cold start, warm start, colour lookup table functions and border colour functions).

func (*TGraphicsOutput) FGraphicsOutputWarmStart

func (t *TGraphicsOutput) FGraphicsOutputWarmStart()

FGraphicsOutputWarmStart is the same as FGraphicsOutputWarmStart except that it does not re-initialize anything, e.g. user defined dither patterns.

func (*TGraphicsOutput) FIcos

func (t *TGraphicsOutput) FIcos()

FIcos is not implemented because it's redundant in nimgobus.

func (*TGraphicsOutput) FIsine

func (t *TGraphicsOutput) FIsine()

FIsine is not implemented because it's redundant in nimgobus.

func (*TGraphicsOutput) FMoveSprite

func (t *TGraphicsOutput) FMoveSprite(s sprite.Sprite, saveTable *sprite.SaveTable, x, y, pose int, xor bool, clippingAreaId int)

FMoveSprite moves an existing sprite on the screen and stores the overwritten data in an saveTable array. Because of the way saveTable has been implemented, this command does not require the "old x, y" as originally documented.

func (*TGraphicsOutput) FPieSlice

func (t *TGraphicsOutput) FPieSlice(xCentre, yCentre, radius, theta1, theta2, colour int)

FPieSlice draws pie slices and filled circles. xCentre and yCentre represent the position of the centre of the circle or pie slice. Radius is the radius along the vertical axis (this is because in high-resolution mode the circle must be stretched across the horizontal axis so it is still a circle). theta1 and theta2 are the starting and stopping angles of the slice, respectively. If theta1 == theta2 then a complete circle will be drawn. theta1 and theta2 are measured in thousandths of a radian, with 0 or 6283 being vertically up (don't ask me, this is how it was originally) and 3142 being vertically down. colour is the colour of the circle (outline and fill colour).

func (t *TGraphicsOutput) FPlonkLogo(x, y int)

FPlonkLogo draws the RM Nimbus logo on the screen, starting with the bottom-left at x, y.

func (*TGraphicsOutput) FPlotCharacterString

func (t *TGraphicsOutput) FPlotCharacterString(orientation, yMagnification, xMagnification, logicalColour, font int, chars string, x, y int)

FPlotCharacterString plots a character string on the screen. orientation: (0-3) the direction to plot, rotated 90 degress anticlockwise each time. yMagnification: (1-50) the amount to enlarge vertically. xMagnification: (1-50) the amount to enlarge horizontally. logicalColour: the colour to plot in, add 256 to plot in XOR mode. font: 0 - use the standard character set, 1 - use the alternative character set (custom charset not yet implemented) chars: the string of chars to plot. x, y: The co-ordinates to plot at.

func (*TGraphicsOutput) FPolyLine

func (t *TGraphicsOutput) FPolyLine(lineStyle int, lineStyleIndex []int, firstLogicalColour, secondLogicalColour, transparency int, geometricData []int)

FPolyLine draws a series of conmnected lines. lineStyle selects the line style to draw with and is in the range 0-6. 0 is a solid line using a dither colour, 1 is a solid line using the first logical colour, 2 is dashed, 3 is dotted, 4 is dash-dotted, 5 is irregular dashed and 6 is user-defined. lineStyleIndex[0] selects the dither pattern to use if lineStyle=0, or defines a custom line style if lineStyle=6 using the entire array, e.g. []int{0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1}. transparency is zero if the second logical colour is to be visible, or 1 if it should be transparent. The shape is drawn in XOR mode if 256 is passed as the first logical colour for dither styles or adding 256 to first logical colour for all other styles. TODO: use [][2]int{} for geometricData

func (*TGraphicsOutput) FPolymarker

func (t *TGraphicsOutput) FPolymarker(markerStyle, markerSizeX, markerSizeY, logicalColour int, markerShape [][2]int, geometricData [][2]int)

FPolymarker draws a series of unconnected markers on the screen. markerStyle: (1-6) the style of marker, 6 being a custom marker defined in markerShape. markerSizeX: (1-50) the x magnification of the marker. markerSizeY: (1-50) the y magnification of the marker. logicalColour: the logical colour of the marker. markerShape: the shape of a custom marker if markerStyle==6, otherwise ignored.

func (*TGraphicsOutput) FReadAreaPixel

func (t *TGraphicsOutput) FReadAreaPixel(xMin, yMin, xMax, yMax int) (img [][]int)

FReadAreaPixel returns the screen memory from a given area of the screen.

func (*TGraphicsOutput) FReadAreaWord

func (t *TGraphicsOutput) FReadAreaWord()

FReadAreaWord is not implemented because it's redundant in nimgobus.

func (*TGraphicsOutput) FReadPixel

func (t *TGraphicsOutput) FReadPixel(x, y int) (colour int)

FReadPixel returns the logical colour of a pixel on the screen.

func (*TGraphicsOutput) FReadToLimit

func (t *TGraphicsOutput) FReadToLimit()

FReadToLimit is not implemented because it looks like an almighty faff to me.

func (*TGraphicsOutput) FReinitGraphicsOutput

func (t *TGraphicsOutput) FReinitGraphicsOutput()

FReinitGraphicsOutput re-initializes the graphics system if it's currently on: - the colour lookup table is initialized. - hatching and dither patterns are set to their default values. - clipping areas 1-9 are set to the full screen. This function is executed during a screen width change and at start-up(?). If the graphics system is currently switch off, ENotInitialized is returned, and the function has not effect.

func (*TGraphicsOutput) FSetBorderColour

func (t *TGraphicsOutput) FSetBorderColour(c int)

FSetBorderColour sets the colour of the screen border. The border cannot flash and its colour is independent of screen resolution. For example, if the entry parameter is 6, the border colour will be set to brown. The error EInvalidParameter is given if the border colour is not in the range 0-15.

func (*TGraphicsOutput) FSetCltElement

func (t *TGraphicsOutput) FSetCltElement(elementNumber, firstPhysicalColour, flashSpeed, secondPhysicalColour int)

FSetCltElement sets an element in the colour lookup table. elementNumber can be in the range 0-15 for low-resolution mode, or 0-3 in high-resolution mode. firstPhysicalColour and secondPhysicalColour can be in the range 0-15. flashSpeed can be in the range 0-2: 0 - no flash, 1 - slow flash, 2 - fast flash. If any parameters are out of range, the error EInvalidParameter is given.

func (*TGraphicsOutput) FSetCurrentOutputClippingArea

func (t *TGraphicsOutput) FSetCurrentOutputClippingArea(id int)

FSetCurrentOutputClippingArea sets the current clipping area. id can be in the range 0-9. 0 is always the full screen. If id is outside 0-9 the error EInvalidParameter is raised.

func (*TGraphicsOutput) FSetDitherPattern

func (t *TGraphicsOutput) FSetDitherPattern(ditherId int, ditherPattern [4][4]int)

FSetDitherPattern sets one of the user-definable dither patterns. ditherId is the number of the dither pattern to be defined (8-15). ditherPattern is the new dither pattern defined in an array, e.g. [4][4]int{{1,2,1,2},{2,1,2,1},{1,2,1,2},{2,1,2,1}}. Note that the maximum colour value in the dither is set according to screen mode, i.e. 3 in high-resolution mode and 15 in low-resolution mode.

func (*TGraphicsOutput) FSetHatchingPattern

func (t *TGraphicsOutput) FSetHatchingPattern(hatchingId int, hatchingPattern [16][16]int)

FSetHatchingPattern sets one of the user-definable dither patterns. hatching is the number of the hacching pattern to be defined (0-5). hatchingPattern is the new hatching pattern defined in an array, e.g. [16][16]int{{1,1,..,0,0},..,{1,1,..,0,0}}. Note that hatching patterns do not store implicit colour information and so the allowed values are either 0 or 1.

func (*TGraphicsOutput) FSetNewClt

func (t *TGraphicsOutput) FSetNewClt(newClt []int)

FSetNewClt replaces the entire colour lookup table with new values. newClt is a list representing the new CLT. If in low-res mode there must be 3*16 values in the list, otherwise 3*4. Each value must be in the range 0-15.

func (*TGraphicsOutput) FSetOutputClippingAreaLimits

func (t *TGraphicsOutput) FSetOutputClippingAreaLimits(id, minX, minY, maxX, maxY int)

FSetOutputClippingAreaLimits defines a clipping area. id is the clipping area id (range: 1 - 9 (0 is not user-definable)) minX, minY, maxX, maxY define the rectangular shape of the clipping area. If any coordinates are outside the screen we get EInvalidParameter. If the minima are greater than the maxima we get EInvalidParameter. If id is out-of-range we get EInvalidParameter.

func (*TGraphicsOutput) FSwapAreaWord

func (t *TGraphicsOutput) FSwapAreaWord()

FSwapAreaWord is not implemented because it's redundant in nimgobus.

func (*TGraphicsOutput) FWriteAreaPixel

func (t *TGraphicsOutput) FWriteAreaPixel(img [][]int, xMin, yMin int, xor bool, ignoreLogicalColour int)

FWriteAreaPixel writes an image array captured by FReadAreaPixel to the screen.

func (*TGraphicsOutput) FWriteAreaWord

func (t *TGraphicsOutput) FWriteAreaWord()

FWriteAreaWord is not implemented because it's redundant in nimgobus.

type THardSums

type THardSums struct {
	// contains filtered or unexported fields
}

THardSums has all the t_hard_maths functions attached to it.

func (*THardSums) FAddTwoReals

func (t *THardSums) FAddTwoReals(a, b float64) float64

FAddTwoReals adds "a" to "b" and returns the result.

func (*THardSums) FArctan

func (t *THardSums) FArctan(a float64) float64

FArctan returns the inverse tangent of "a".

func (*THardSums) FAsciiToReal

func (t *THardSums) FAsciiToReal(a string) float64

FAsciiToReal converts the string representation of a float to float.

func (*THardSums) FCommonLog

func (t *THardSums) FCommonLog(a float64) float64

FCommonLog returns the log to base 10 of "a".

func (*THardSums) FCosine

func (t *THardSums) FCosine(a float64) float64

FCosine returns the cosine of "a".

func (*THardSums) FDivideReals

func (t *THardSums) FDivideReals(a, b float64) float64

FDivideReals divides "b" by "a" and returns the result.

func (*THardSums) FIntLessThanReal

func (t *THardSums) FIntLessThanReal(a float64) int

FIntLessThanReal basically floors a real and returns an int.

func (*THardSums) FIntPartOfReal

func (t *THardSums) FIntPartOfReal(a float64) int

FIntPartOfReal returns the integer part of "a" as an int.

func (*THardSums) FInverseNaturalLog

func (t *THardSums) FInverseNaturalLog(a float64) float64

FInverseNaturalLog returns the inverse natural log of "a". Note that this function uses 2.7182 as the base, as described in the Nimbus SUBBIOS documentation.

func (*THardSums) FMultiplyReals

func (t *THardSums) FMultiplyReals(a, b float64) float64

FMultiplyReals multiplies "a" by "b" and returns the result.

func (*THardSums) FNaturalLog

func (t *THardSums) FNaturalLog(a float64) float64

FNaturalLog returns the natural log of "a".

func (*THardSums) FRaiseToPower

func (t *THardSums) FRaiseToPower(a float64, b int) float64

FRaiseToPower raises a float to an integer power.

func (*THardSums) FRealFromInt

func (t *THardSums) FRealFromInt(a int) float64

FRealFromInt converts an integer to floating point.

func (*THardSums) FRealToAscii

func (t *THardSums) FRealToAscii(a float64) string

FRealToAscii returns the string representation of "a".

func (*THardSums) FSine

func (t *THardSums) FSine(a float64) float64

FSine returns the sine of "a".

func (*THardSums) FSquareRoot

func (t *THardSums) FSquareRoot(a float64) float64

FSquareRoot returns the square root of "a".

func (*THardSums) FSubtractReals

func (t *THardSums) FSubtractReals(a, b float64) float64

FSubtractReals subtracts "a" from "b" and returns the result.

func (*THardSums) FTangent

func (t *THardSums) FTangent(a float64) float64

FTangent returns the tangent of "a".

func (*THardSums) FTruncateReal

func (t *THardSums) FTruncateReal(a float64) float64

FTruncateReal returns the integer part of "a" as a float.

Directories

Path Synopsis
Package colour defines all the default Nimbus colour settings
Package colour defines all the default Nimbus colour settings
Package errorcode defines constants for the subbios error codes.
Package errorcode defines constants for the subbios error codes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL