diff --git a/Programs/CosmOS/Apps/Lander.asm b/Programs/CosmOS/Apps/Lander.asm index 0d27eb5..c5b6d0a 100644 --- a/Programs/CosmOS/Apps/Lander.asm +++ b/Programs/CosmOS/Apps/Lander.asm @@ -88,6 +88,13 @@ start: CALL mulReady ; The quarter square table, once. The orbit below needs a product. CALL putTiles + + ; Key mode before the splash, because "press anything" needs the keystroke as it happens + ; rather than a line at the end of one. + INIA 0x01 + OUTA 0x02 + CALL splash + CALL makeMoon CALL carvePads CALL drawMoon @@ -95,9 +102,6 @@ start: CALL putGauge CALL putOrbital - INIA 0x01 - OUTA 0x02 ; Key mode. - ; ---- Is there a controller ---- ; ; Asked once, and about all four. If there is one anywhere, the console's arrow keys are @@ -3541,6 +3545,168 @@ groundLevel: STA.0 RET +; ---- The studio, and its theme ---- +; +; What a splash screen is: whose game this is, over whatever music they want it said to. The +; game's own title screen is a different thing and comes later. +; +; IT POLLS THE TIMER RATHER THAN BEING INTERRUPTED BY IT. This program has no vector segment +; and waits for the screen by reading port 0x30, so waiting for a beat by reading port 0x50 is +; the same shape - and it means the splash brings no handler that would have to be taken away +; before the game starts. Reading the status is what answers a tick nobody was interrupted by. +; +; A tune that is not there is not a failure. The logo still shows, for a moment measured in +; frames instead of ticks, and the game starts. That is what /lander.state does too. +splash: + ; ---- Somebody already leaning on something means no splash at all ---- + ; + ; Asked before anything is drawn or read, so that skipping costs nothing: the alternative + ; blanks twenty five rows of window and reads a file off the disk before it thinks to look, + ; which is a fifth of a second spent showing a picture nobody wanted. + CALL splashSkip + BNQ splashNone + + ; ---- The whole screen is window while the splash is up ---- + ; + ; Port 0x3D is how many window rows are SHOWN, and putGauge sets it to two later for the + ; gauge. Two is not enough to put a line in the middle of the screen, and until putGauge + ; runs it is not even that - so the splash asks for all of them, which has the second use of + ; hiding the map, where the shell's prompt is still sitting. + INIA 0d25 + OUTA 0x3D + RSTA + OUTA 0x3E ; From the top. + + ; Blanked a row at a time, because what is in the window is whatever was there before. A + ; CALL hands back A and B, so the row and the count both survive it. + INIB 0d25 ; A is already nought, from setting the window's top above. +splashBlank: + SETD.0 Nothing + CALL sayAtRow + INCA + DECB + BNB splashBlank + + SETD.0 StudioLine + INIA 0d11 + CALL sayAtRow + + SETD.0 SplashTune + SETD.1 SplashBuffer + SWI osFileRead + BNQ splashSilent + + SETD.0 SplashBuffer + CALL useTune ; Which sets the tick out of the tune's own header. + BNQ splashSilent + + INIA 0x03 + OUTA 0x51 ; Run and repeat. NO interrupt: this waits by looking. + +splashPlay: + SETD.1 Voice0 + RSTA + CALL stepVoice + SETD.1 Voice1 + INIA 0d1 + CALL stepVoice + SETD.1 Voice2 + INIA 0d2 + CALL stepVoice + SETD.1 Voice3 + INIA 0d3 + CALL stepVoice + + SETD.1 Playing + LDA.1 + BRA splashDone ; Every voice has run out of order list. + CALL splashSkip + BNQ splashDone + CALL waitTick + BRI splashPlay + +splashSilent: + ; No tune on the disk, so the logo is held for about a second and a half of frames. + INIB 0d90 +splashHold: + CALL waitFrame + CALL splashSkip + BNQ splashDone + DECB + BNB splashHold + +splashDone: + RSTA + OUTA 0x51 ; The timer stopped, whether or not it was ever started. + CALL hushVoices + + ; And the window given back, because putGauge is about to ask for the two rows it wants. + RSTA + OUTA 0x3D +splashNone: + RET + +; ---- Anything pressed, on a pad or a key ---- +; +; THE ANSWER COMES BACK IN Q, because Q is what survives a RET. A CALL saves and restores A, +; so a routine that answered there would hand its caller back the A it already had - which +; here was the channel number the last stepVoice was given, and the splash ended on its first +; pass every time whatever anybody pressed. nextRandom above says the same thing about the +; same register, which is where it should have been read. +splashSkip: + CALL readPad + SETD.0 Held + LDA.0 + INIB 0x50 ; A, or Start - the same two waitKey asks about, and for the same + AND ; reason: a direction held on a stick is not somebody asking to + BNQ splashSkipYes ; begin, and ANY bit counted one as such. + INA 0x01 + INIB 0x01 ; READY + AND + BRQ splashSkipNo + INA 0x00 ; Taken, so it is not still waiting at the prompt afterwards. + BRA splashSkipNo ; A NOUGHT IS NOT A KEYPRESS. It is what a recorded keyboard file + ; holds while nobody is typing, and what readControls has always + ; ignored - a splash that took it for a key would be a splash + ; nothing could ever watch. +splashSkipYes: + INIA 0d1 + RSTB + OR ; Q is one: somebody asked for the game. + RET +splashSkipNo: + RSTA + RSTB + OR ; And Q is nought: nobody did. + RET + +; A beat, waited for by looking - the same shape as waitFrame, one device along. Reading the +; status is what brings the tick down. +waitTick: + INA 0x50 + INIB 0x01 + AND + BRQ waitTick + RET + +; Every voice let go of. The splash owns all four while it plays and the game wants them back +; silent - and every sound in this game loads its own patch before its note, so nothing else +; has to be put back. +hushVoices: + RSTA +hushOne: + OUTA 0x41 + PSHA + RSTA + OUTA 0x45 + POPA + INCA + INIB 0d4 + CCF + SUB + BNQ hushOne + RET + ; ---- A line of text, into the window ---- ; ; DP0 names a string. It goes into window row one and the rest of the row is BLANKED, so a @@ -3554,12 +3720,21 @@ groundLevel: ; The letters are ordinary tiles: the character generator starts at the space, so glyph n is ; character n less thirty two. sayInWindow: + INIA 0d1 ; Row one, which is where a base's message goes. +sayAtRow: + ; A is which window row. Kept in memory across the bank select below, which needs A itself. + SETD.1 SayRow + STA.1 INIA 0d5 - OUTA 0xE3 - INIA 0xC1 + OUTA 0xE3 ; Which needs A, so the row came out of it a moment ago. + LDA.1 ; DP1 still holds SayRow. + INIB 0xC0 + CCF + ADD ; Window row n begins at 0xC000 plus n times 256. + MVQA OUTA 0xE4 RSTA - OUTA 0xE5 ; Window row one begins at 0xC100. + OUTA 0xE5 SETD.1 SayAt STA.1 @@ -4072,6 +4247,17 @@ Wide: ; ; Named rather than numbered, so whatever writes one and this that reads it are describing the ; same fields. Low byte first, the way every other word here is. +SayRow: + 0d1 +StudioLine: +" ANACHRONAUT" +Nothing: + 0x00 +SplashTune: +"/splash.tune" +SplashBuffer: + #Reserve 0d1024 + StateName: "/lander.state" StateBuffer: @@ -4480,6 +4666,8 @@ LanderArtAt: #Include math.asm +#Include player.asm + #Include boom.asm #Include alarm.asm diff --git a/Programs/CosmOS/README.md b/Programs/CosmOS/README.md index 520751e..5c5a53d 100644 --- a/Programs/CosmOS/README.md +++ b/Programs/CosmOS/README.md @@ -731,7 +731,7 @@ from every assembly file in it. Several are old programs written for the bare ma | Grid | The first program to use the screen as a screen. Redefines a tile above the font, fills all 128 map rows, and scrolls it diagonally a pixel at a time. | | Sprite | Moves a ball across the shell's own text, writing not one byte of the map to do it. It leaves the sprite in the table on the way out, because clearing them is the system's job - see below. | | Pad | Says what the controllers are doing, printing a line whenever one changes. It tells apart the three things that look identical from inside a game that is not responding: a pad nobody noticed, a pad mapped to nothing, and a mapping that is wrong. | -| Lander | Lunar Porter, rung one: a lander over a moon that wraps. Flown with a controller if there is one - a held thruster burns every tick it is held for - and with the arrow keys if there is not, where one press is one burn and that is the most the console can say. A bar at the bottom is the sideways drift, drawn as a sprite stretched to the speed - a moon has no air, so a drift never stops by itself and stopping one means cancelling it exactly, which is hard to do blind. A flight begins where a flight begins: run does not reload, so the numbers the assembler wrote are load-time values and an init routine puts back the ones a new flight needs - including the terrain seed, which is a written number, so the moon is the same moon every time rather than whatever the last run's random walk left behind. What is not on that list keeps what the last run left it, which is a decision rather than an oversight. It lands or crashes on arrival, and what decides is the speed at the moment it touches: gentler than three quarters of a pixel a frame downwards and half of one sideways, or it is a lander on its side. A fuel gauge sits in the window layer, where the moon turning underneath cannot scroll it away, and every thruster costs a unit of fuel every tick it fires. It turns from green to red at a quarter of a tank, and a warning sounds ONCE on the way down through it - once, because a lander is at its most careful in the last seconds before it touches and something repeating in its ear through that is a distraction rather than a warning. Filling up at a base allows it again. The sound is the moment it happened and the colour is how things stand, and both come off the same number so they cannot disagree. An empty tank is not an ending: it is a lander still flying that can no longer do anything about where. Four landing pads are carved into the moon after it is generated, levelled to whatever height their first column happened to have, and marked in cyan by an attribute rather than a tile of their own. The lander starts above one, because that is where a porter's day begins. Each pad is a base, told apart by the colour it is drawn in, and landing at one either loads cargo for the base across the moon or delivers what is aboard and pays eighty units of fuel. A landing is not an ending: the lander rests where it is until the throttle opens again, and A or Start says "read it" as readily as a key does. What a base says goes in the window rather than out of the console: the console draws into the map, so a message printed while flying is one the lander then flies over, and printing scrolls the whole world up a row. Opening the throttle wipes the line. Two bars read the speeds and are green while a landing would survive and red while it would not, so "can I put down" is a glance rather than a sum. A third runs up the left edge and is how much sky is under the lander, half a pixel of bar to a pixel of it; it reads nought the moment the lander is down, and it exists because the orbit takes the lander off the top of the screen and a panel that only works while the ground is in sight is no use above it. And gravity here is the pull MINUS the swing outwards, which is what makes an orbit rather than a one way trip: under four pixels a frame sideways the pull wins and the lander falls, over it the swing wins and the lander climbs, and at it they cancel and it circles. Falling buys sideways speed and climbing spends it - at a rate set by the product of the two, so the trade stops by itself as the sideways speed runs out - and that is the cycle: a fall carries the lander past orbital speed and becomes a climb, the climb pays it back and becomes a fall, periapse and apoapse, round and round. Orbital speed is marked on the drift bar, sixty four pixels either side of the middle, because a number nothing points at is folklore. Gravity never falls off and the moon wraps, so a circular orbit is the same length at any height and one orbital speed serves everywhere. There is a ceiling 192 pixels above the world's origin, which is the top of the wide view - it was sixty four while sixty four was all the sky a forty column screen had over the origin, which was a fact about the view rather than about the world. It pins rather than ends: leaving upward is recoverable, so the lander is held there and told so, and one sideways is spent every tick it tries to climb - without that the pin wiped the climb, the trade saw neither fall nor climb, and the speed pushing it up never changed. What kills you out here is running dry a long way from the ground. B, or z on the keyboard, swaps the screen between forty columns and eighty, which is the same map, the same cells and the same engine at half the size: nearly two thirds of the moon at once for the orbit, and twice as big for the landing. The twenty extra rows that buys go to the SKY and not to the moon - the wide view starts twenty four rows above the world's origin rather than at it, so the ground sits near the bottom and the whole flyable band is on the screen. Drawn down from the origin instead it was 71 per cent rock, which is a zoom that shows you more of the thing you cannot fly through. A lander at the ceiling is off the top of a forty column screen, which is where the orbit lives and why the altitude bar had to exist; zoomed out it is in the picture. And there is a station up there, twelve rows above the world's origin - about two thirds of the way from the ground to the ceiling, clear of work near the surface - going round at orbital speed - which needs no physics of its own, because a body at 64 sixteenths is exactly what a circular orbit IS under these rules, at any height, since gravity never falls off and the moon wraps. It is off the top of a forty column screen too, so it is somewhere to go that the zoom is needed to see. Docking it is landing on something that is moving: close enough, and slow enough RELATIVE TO THE STATION, or it is a wreck. Its speed is orbital speed, which is the number the marks on the drift bar point at, so the instrument for it was on the screen before there was anything to dock with. A dock pays eighty units of fuel and holds the lander a tile under the station until a thruster lets go, sliding it into line at half a pixel a frame rather than snapping - a dock is allowed eight pixels out either way, so putting the lander exactly in place the instant it took hold moved it a whole tile in one frame, right at the moment the player was being told they had been careful. It settles squarely under the port, which it did not used to: the lander is drawn from half a screen LESS HALF A TILE, because that is what centres it, and the station was drawn from half a screen exactly, so a perfectly flown dock still looked four pixels out. Getting there is a two burn manoeuvre and not a straight line: climbing SPENDS sideways speed, so a lander cannot rise while matched - it arrives slower than orbital every time, and has to raise the far side of its orbit and then circularise at the top. Which is also why it reads /lander.state if the disk has one: sixteen bytes of position, velocity, station, fuel and screen, laid straight over the numbers it would otherwise start with, so a rendezvous can be examined without flying one first. A disk without the file is the game as it always was. The buffer is a whole block wide because osFileRead lands a file in blocks of 256, and sixteen bytes of room for it wrote over everything that followed. A landing kicks up dust, sideways and up off the lander's feet, because that is where kicked dust goes and there is ground in the way of the rest of it. Letting go of the station vents gas instead, evenly in every direction, since nothing is in the way of a docking port - and that one does NOT stop the world the way the others do, because it goes off on the frame a thruster is pressed and freezing then would be felt as the controls sticking. There is none on docking: a dock is a catch and not a touchdown, and there is nothing under it to kick. A lander also has to get two tiles clear of the station before it can take hold of it again, because a docked one sits exactly one tile under it - so letting go upwards docked it straight back on, took the fuel again, and sat waiting to be told the message had been read. A thruster bangs when it lights and rumbles while it burns, and EVERY thruster that catches bangs - a pilot already burning upwards who then adds a sideways one has lit an engine, so what is watched is which of them are lit rather than whether any is. The rumble is struck once and runs until every one is out, since restriking it when a second joins would start its attack over, which is a stutter rather than an engine, and the rumble is a HELD note: its gate goes down when one lights and does not come up until every one is out - or until anything stops to wait, because a held note outlives the loop that was holding it and landing on the thruster used to leave it roaring under the verdict. Arriving somewhere latches two notes quickly, middle C then the C above for taking hold of the station and the same pair reversed for letting go, two octaves lower for the ground. The second note is pending rather than played, since at an undocking the pilot is mid-burn and stopping the world for an eighth of a second would be felt as the controls sticking. Four channels for five sounds: the bang and the latch share one, because a lander arriving either arrives or does not and a crash ends the run outright. No instrument is set up once at startup: each sound loads its patch immediately before its note, because the bang and the latch share a channel and a channel used by two sounds has to be told which of them it is about to be. That rule arrived as a workaround for something worse - an LFO used to belong to the DEVICE and not to a channel, so whichever patch was loaded last owned both of them for every voice at once, which is what made the warning's trill vanish after the first landing of a run when the landing's patch carried an LFO switched off. An intermittent fault of the worst kind, right until something unrelated plays and right again next time the machine starts. Loading at the note fixed each sound as it STARTED and could not fix two of them overlapping, so the device was changed instead and an LFO now belongs to the channel it was written to. A crash also makes a noise, which was the first sound this game had, and it is a TRIGGERED voice - struck once and then playing its own length, so nothing has to come back and end it. That the program says so rather than the patch is deliberate: the patch decides what the bang sounds like and the program decides that it is a bang. It is noise through a low pass that the modulation envelope shuts as the level falls, so the bright part is only at the front and it is a boom rather than a hiss. The instrument is built at startup the way the tiles are, because a patch is twenty odd writes and a note is two - which is what the selector and value registers are for. It plays on channel THREE: effects count down from the top so that music, if it ever arrives, can take nought and count up and the two never have to negotiate. A crash takes the lander apart: it goes, and six pieces of it leave in a rough hexagon at its own colour for about a second before the verdict is said. It used to be a line of text and a lander still sitting there in one piece, so a watcher had to read the words to know what had happened. The world is not running while that plays - it is a loop of its own, so nothing else has to know how to be half destroyed. A plume hangs off whichever side the engine is pushing from - under the lander to lift, over it to retro, and on the far side from the way it is being pushed sideways, since that is where the gas leaves. Every other reading here is a number drawn as a bar and all of them say what is happening TO the lander, so without this a watcher has to read gauges to work out that a thruster is even lit. It is drawn while the BUTTON IS HELD rather than while the engine fires: the engine fires one frame in ten, because that is the tick gravity is applied on, and a flame that honest is a fault lamp rather than a rocket. An empty tank draws none, and neither does the retro thruster on the ground, because in both cases the button really is doing nothing. Down is a retro thruster at half the strength of up - one sixteenth a tick against two, which is exactly gravity's own step, so it can stop a climb and hurry a descent and can never turn a landing approach into a crash faster than letting go would. Arresting a rise otherwise meant a sideways burn and a wait for the orbit to come round, which is how a rendezvous really is flown and a lot to ask of somebody who has not flown one. It does nothing at all to a lander on the ground, which is not politeness: touchdown has already had its say and will not speak again, so without that guard a landed lander holding it goes straight through the moon. | +| Lander | Lunar Porter, rung one: a lander over a moon that wraps. Flown with a controller if there is one - a held thruster burns every tick it is held for - and with the arrow keys if there is not, where one press is one burn and that is the most the console can say. A bar at the bottom is the sideways drift, drawn as a sprite stretched to the speed - a moon has no air, so a drift never stops by itself and stopping one means cancelling it exactly, which is hard to do blind. It opens on a splash: the studio, and whatever /splash.tune holds, played over it before the world is built. Lander includes Libraries/player.asm and owns the timer and all four channels while it plays, because nothing else is happening yet - and it POLLS the timer rather than being interrupted by it, the same way it waits for the screen, so it brings no handler that would have to be taken away before the game starts. Any key or A or Start skips it, and one already held when it begins means no splash at all rather than a picture nobody wanted; a missing tune means the logo and silence, the way a missing /lander.state means the defaults stand. A flight begins where a flight begins: run does not reload, so the numbers the assembler wrote are load-time values and an init routine puts back the ones a new flight needs - including the terrain seed, which is a written number, so the moon is the same moon every time rather than whatever the last run's random walk left behind. What is not on that list keeps what the last run left it, which is a decision rather than an oversight. It lands or crashes on arrival, and what decides is the speed at the moment it touches: gentler than three quarters of a pixel a frame downwards and half of one sideways, or it is a lander on its side. A fuel gauge sits in the window layer, where the moon turning underneath cannot scroll it away, and every thruster costs a unit of fuel every tick it fires. It turns from green to red at a quarter of a tank, and a warning sounds ONCE on the way down through it - once, because a lander is at its most careful in the last seconds before it touches and something repeating in its ear through that is a distraction rather than a warning. Filling up at a base allows it again. The sound is the moment it happened and the colour is how things stand, and both come off the same number so they cannot disagree. An empty tank is not an ending: it is a lander still flying that can no longer do anything about where. Four landing pads are carved into the moon after it is generated, levelled to whatever height their first column happened to have, and marked in cyan by an attribute rather than a tile of their own. The lander starts above one, because that is where a porter's day begins. Each pad is a base, told apart by the colour it is drawn in, and landing at one either loads cargo for the base across the moon or delivers what is aboard and pays eighty units of fuel. A landing is not an ending: the lander rests where it is until the throttle opens again, and A or Start says "read it" as readily as a key does. What a base says goes in the window rather than out of the console: the console draws into the map, so a message printed while flying is one the lander then flies over, and printing scrolls the whole world up a row. Opening the throttle wipes the line. Two bars read the speeds and are green while a landing would survive and red while it would not, so "can I put down" is a glance rather than a sum. A third runs up the left edge and is how much sky is under the lander, half a pixel of bar to a pixel of it; it reads nought the moment the lander is down, and it exists because the orbit takes the lander off the top of the screen and a panel that only works while the ground is in sight is no use above it. And gravity here is the pull MINUS the swing outwards, which is what makes an orbit rather than a one way trip: under four pixels a frame sideways the pull wins and the lander falls, over it the swing wins and the lander climbs, and at it they cancel and it circles. Falling buys sideways speed and climbing spends it - at a rate set by the product of the two, so the trade stops by itself as the sideways speed runs out - and that is the cycle: a fall carries the lander past orbital speed and becomes a climb, the climb pays it back and becomes a fall, periapse and apoapse, round and round. Orbital speed is marked on the drift bar, sixty four pixels either side of the middle, because a number nothing points at is folklore. Gravity never falls off and the moon wraps, so a circular orbit is the same length at any height and one orbital speed serves everywhere. There is a ceiling 192 pixels above the world's origin, which is the top of the wide view - it was sixty four while sixty four was all the sky a forty column screen had over the origin, which was a fact about the view rather than about the world. It pins rather than ends: leaving upward is recoverable, so the lander is held there and told so, and one sideways is spent every tick it tries to climb - without that the pin wiped the climb, the trade saw neither fall nor climb, and the speed pushing it up never changed. What kills you out here is running dry a long way from the ground. B, or z on the keyboard, swaps the screen between forty columns and eighty, which is the same map, the same cells and the same engine at half the size: nearly two thirds of the moon at once for the orbit, and twice as big for the landing. The twenty extra rows that buys go to the SKY and not to the moon - the wide view starts twenty four rows above the world's origin rather than at it, so the ground sits near the bottom and the whole flyable band is on the screen. Drawn down from the origin instead it was 71 per cent rock, which is a zoom that shows you more of the thing you cannot fly through. A lander at the ceiling is off the top of a forty column screen, which is where the orbit lives and why the altitude bar had to exist; zoomed out it is in the picture. And there is a station up there, twelve rows above the world's origin - about two thirds of the way from the ground to the ceiling, clear of work near the surface - going round at orbital speed - which needs no physics of its own, because a body at 64 sixteenths is exactly what a circular orbit IS under these rules, at any height, since gravity never falls off and the moon wraps. It is off the top of a forty column screen too, so it is somewhere to go that the zoom is needed to see. Docking it is landing on something that is moving: close enough, and slow enough RELATIVE TO THE STATION, or it is a wreck. Its speed is orbital speed, which is the number the marks on the drift bar point at, so the instrument for it was on the screen before there was anything to dock with. A dock pays eighty units of fuel and holds the lander a tile under the station until a thruster lets go, sliding it into line at half a pixel a frame rather than snapping - a dock is allowed eight pixels out either way, so putting the lander exactly in place the instant it took hold moved it a whole tile in one frame, right at the moment the player was being told they had been careful. It settles squarely under the port, which it did not used to: the lander is drawn from half a screen LESS HALF A TILE, because that is what centres it, and the station was drawn from half a screen exactly, so a perfectly flown dock still looked four pixels out. Getting there is a two burn manoeuvre and not a straight line: climbing SPENDS sideways speed, so a lander cannot rise while matched - it arrives slower than orbital every time, and has to raise the far side of its orbit and then circularise at the top. Which is also why it reads /lander.state if the disk has one: sixteen bytes of position, velocity, station, fuel and screen, laid straight over the numbers it would otherwise start with, so a rendezvous can be examined without flying one first. A disk without the file is the game as it always was. The buffer is a whole block wide because osFileRead lands a file in blocks of 256, and sixteen bytes of room for it wrote over everything that followed. A landing kicks up dust, sideways and up off the lander's feet, because that is where kicked dust goes and there is ground in the way of the rest of it. Letting go of the station vents gas instead, evenly in every direction, since nothing is in the way of a docking port - and that one does NOT stop the world the way the others do, because it goes off on the frame a thruster is pressed and freezing then would be felt as the controls sticking. There is none on docking: a dock is a catch and not a touchdown, and there is nothing under it to kick. A lander also has to get two tiles clear of the station before it can take hold of it again, because a docked one sits exactly one tile under it - so letting go upwards docked it straight back on, took the fuel again, and sat waiting to be told the message had been read. A thruster bangs when it lights and rumbles while it burns, and EVERY thruster that catches bangs - a pilot already burning upwards who then adds a sideways one has lit an engine, so what is watched is which of them are lit rather than whether any is. The rumble is struck once and runs until every one is out, since restriking it when a second joins would start its attack over, which is a stutter rather than an engine, and the rumble is a HELD note: its gate goes down when one lights and does not come up until every one is out - or until anything stops to wait, because a held note outlives the loop that was holding it and landing on the thruster used to leave it roaring under the verdict. Arriving somewhere latches two notes quickly, middle C then the C above for taking hold of the station and the same pair reversed for letting go, two octaves lower for the ground. The second note is pending rather than played, since at an undocking the pilot is mid-burn and stopping the world for an eighth of a second would be felt as the controls sticking. Four channels for five sounds: the bang and the latch share one, because a lander arriving either arrives or does not and a crash ends the run outright. No instrument is set up once at startup: each sound loads its patch immediately before its note, because the bang and the latch share a channel and a channel used by two sounds has to be told which of them it is about to be. That rule arrived as a workaround for something worse - an LFO used to belong to the DEVICE and not to a channel, so whichever patch was loaded last owned both of them for every voice at once, which is what made the warning's trill vanish after the first landing of a run when the landing's patch carried an LFO switched off. An intermittent fault of the worst kind, right until something unrelated plays and right again next time the machine starts. Loading at the note fixed each sound as it STARTED and could not fix two of them overlapping, so the device was changed instead and an LFO now belongs to the channel it was written to. A crash also makes a noise, which was the first sound this game had, and it is a TRIGGERED voice - struck once and then playing its own length, so nothing has to come back and end it. That the program says so rather than the patch is deliberate: the patch decides what the bang sounds like and the program decides that it is a bang. It is noise through a low pass that the modulation envelope shuts as the level falls, so the bright part is only at the front and it is a boom rather than a hiss. The instrument is built at startup the way the tiles are, because a patch is twenty odd writes and a note is two - which is what the selector and value registers are for. It plays on channel THREE: effects count down from the top so that music, if it ever arrives, can take nought and count up and the two never have to negotiate. A crash takes the lander apart: it goes, and six pieces of it leave in a rough hexagon at its own colour for about a second before the verdict is said. It used to be a line of text and a lander still sitting there in one piece, so a watcher had to read the words to know what had happened. The world is not running while that plays - it is a loop of its own, so nothing else has to know how to be half destroyed. A plume hangs off whichever side the engine is pushing from - under the lander to lift, over it to retro, and on the far side from the way it is being pushed sideways, since that is where the gas leaves. Every other reading here is a number drawn as a bar and all of them say what is happening TO the lander, so without this a watcher has to read gauges to work out that a thruster is even lit. It is drawn while the BUTTON IS HELD rather than while the engine fires: the engine fires one frame in ten, because that is the tick gravity is applied on, and a flame that honest is a fault lamp rather than a rocket. An empty tank draws none, and neither does the retro thruster on the ground, because in both cases the button really is doing nothing. Down is a retro thruster at half the strength of up - one sixteenth a tick against two, which is exactly gravity's own step, so it can stop a climb and hurry a descent and can never turn a landing approach into a crash faster than letting go would. Arresting a rise otherwise meant a sideways burn and a wait for the orbit to come round, which is how a rendezvous really is flown and a lot to ask of somebody who has not flown one. It does nothing at all to a lander on the ground, which is not politeness: touchdown has already had its say and will not speak again, so without that guard a landed lander holding it goes straight through the moon. | | Depth | Four pillars at four distances and a ball walking past them, behind the near ones and in front of the far ones. The ball is sprite nought and every pillar is numbered after it, so table order puts it in front of all four - what actually decides is the depth buffer, asked a column at a time. | | Flip | Draws a whole screen into the bank that is not being shown, waits, and then shows it in one byte out of one port. It writes nothing else at all - not a tile, not a colour - so it does not ask for the screen to be saved, and the line it printed is still there when it comes back. It deliberately does not put the displayed screen back either, because that is the system's to restore: a program that faulted while flipped could not have. | | Edit | A line editor. | diff --git a/Programs/Libraries/player.asm b/Programs/Libraries/player.asm index 76a36cd..eebbecb 100644 --- a/Programs/Libraries/player.asm +++ b/Programs/Libraries/player.asm @@ -16,9 +16,11 @@ ; PatchTable one two-byte address per patch ; SequenceTable one two-byte address per sequence ; VoiceStart four bytes, the patch index each voice starts on -; Order0..Order3 one-byte sequence indices each, ending in 0xFF ; -; and must call loadStartPatches once, then stepVoice once a tick for each voice, with A +; and point each voice's order cursor at a list of one-byte sequence indices ending in 0xFF. +; A tune read from a file needs none of that: useTune does all of it out of the header. +; +; It must call loadStartPatches once, then stepVoice once a tick for each voice, with A ; holding the channel and DP1 the voice's record. Playing counts down as voices run out, and ; reaching nought is the piece being over. ; @@ -424,13 +426,13 @@ loadPatchPair: ; tick runs the count out, finds the end, and goes to the order list for the real first ; sequence - so the beginning of a piece needs no special case anywhere. Voice0: - Order0 Empty 0d1 0d1 + NoOrder Empty 0d1 0d1 Voice1: - Order1 Empty 0d1 0d1 + NoOrder Empty 0d1 0d1 Voice2: - Order2 Empty 0d1 0d1 + NoOrder Empty 0d1 0d1 Voice3: - Order3 Empty 0d1 0d1 + NoOrder Empty 0d1 0d1 Playing: 0d4 @@ -455,6 +457,14 @@ TuneSequences: TuneMagic: 0x53 0x42 0x54 0x55 0x01 ; "SBTU" and version one. +; An order list of nothing, which every voice starts pointed at. WHOEVER SUPPLIES THE TUNE +; SETS THE REAL ONE - useTune out of a file's header, or a program with a tune of its own in +; eight lines - so the records below name nothing that a caller has to have defined. They used +; to name Order0 to Order3, which made four order lists part of the contract even for a caller +; whose tune comes from a file and never has any. +NoOrder: + 0xFF + ; The sequence a voice starts on, so that its first tick goes through the order list like ; every other bar does. Empty: diff --git a/Programs/Tunes/splash.tune.txt b/Programs/Tunes/splash.tune.txt new file mode 100644 index 0000000..e2b601e --- /dev/null +++ b/Programs/Tunes/splash.tune.txt @@ -0,0 +1,67 @@ +; Four bars, and the bass is the same one under two of them. +#Tick 0d125000 ; cycles a tick: a sixteenth note at 120 beats a minute + +#Patch Oboe oboe.patch + +#Voice 0d0 Oboe ; which instrument each voice starts on +#Voice 0d1 Oboe +#Voice 0d2 Oboe +#Voice 0d3 Oboe + +#Sequence MotifA + 0x30 0d2 + 0x00 0d2 + 0x3C 0d2 + 0x00 0d4 + 0x48 0d4 + 0x00 0d4 + 0x47 0d4 + 0x00 0d6 + ; 28 beats + +#Sequence MotifB + 0x00 0d2 + 0x35 0d2 + 0x00 0d2 + 0x40 0d4 + 0x00 0d4 + 0x45 0d4 + 0x00 0d4 + 0x43 0d6 + + +#Sequence IntroQuiet + 0x00 0d28 + +#Sequence ChordRoot + 0x2C 0x4 + 0x2E 0x4 + 0x30 0x4 + +#Sequence ChordFifth + 0x33 0x4 + 0x35 0x4 + 0x37 0x4 + +#Sequence ChordThird + 0x3C 0x4 + 0x3E 0x4 + 0x40 0x4 + +#Sequence ChordQuiet + 0x00 0d12 + +#Sequence Bass + 0x24 0x8 + +#Order 0d0 + MotifA ChordRoot + +#Order 0d1 + MotifB ChordFifth + +#Order 0d2 + IntroQuiet ChordThird + +#Order 0d3 + IntroQuiet ChordQuiet Bass diff --git a/Tests/expected/cosmosCrossDisk.out b/Tests/expected/cosmosCrossDisk.out index a472407..d5821db 100644 --- a/Tests/expected/cosmosCrossDisk.out +++ b/Tests/expected/cosmosCrossDisk.out @@ -25,14 +25,15 @@ Mode.sbx 48 Flip.sbx 173 Sprite.sbx 442 Depth.sbx 672 -Lander.sbx 9361 +Lander.sbx 11260 Pad.sbx 264 Crash.sbx 632 vars.script 50 blocks.script 343 loops.script 272 +splash.tune 218 tune.sbx 318 -Play.sbx 2525 +Play.sbx 2526 notes.txt 21 Apps