Annotation of frontvm/notes.txt, revision 1.1.1.3

1.1       root        1: 
                      2: outstanding introduced/emulation bugs:
                      3: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                      4: 
1.1.1.2   root        5: search for 'XXX' in fe2.s to find comments on known breakage.
1.1       root        6: 
1.1.1.3 ! root        7: 462(a5) arg d1:
        !             8: 
        !             9: 0x0    last thingy? always player's ship?
        !            10: 0x2    *hmm...*
        !            11: 0x4    *crash!*
        !            12: 0x6    prox mine
        !            13: 0x8    prox mine
        !            14: 0xa    missile
        !            15: 0xc    smart missile
        !            16: 0xe    naval missile
        !            17: 0x10   nuclear missile
        !            18: 0x12   escape capsule
        !            19: 0x14   interplanetary shuttle
        !            20: 0x16   lifter
        !            21: 0x18   osprey
        !            22: 0x1a   falcon attack fighter
        !            23: 0x1c   hawk airfighter
        !            24: 0x1e   kestrel 
        !            25: 0x20   eagle
        !            26: 0x22   eagle II
        !            27: 0x24   eagle III
        !            28: 0x26   sidewinder
        !            29: 0x28   krait
        !            30: 0x2a   gecko
        !            31: 0x2c   adder
        !            32: 0x2e   viper
        !            33: 0x30   cobra 1
        !            34: 0x32   moray starboat
        !            35: 0x34   cobra 3
        !            36: 0x36   constrictor
        !            37: 0x38   asp
        !            38: 0x3a   transporter
        !            39: 0x3c   lion
        !            40: 0x3e   tiger
        !            41: 0x40   imperial courier
        !            42: 0x42   python
        !            43: 0x44   imperial trader
        !            44: 0x46   anaconda
        !            45: 0x48   puma
        !            46: 0x4a   boa
        !            47: 0x4c   panther clipper
        !            48: 0x4e   big thargoid ship...
        !            49: 0x50   lynx bulk carrier
        !            50: 0x52   long range cruiser
        !            51: 0x54   lave type small space station
        !            52: 0x56   hoop type space station
        !            53: 0x58   orbital city
        !            54: 0x5a   4-berth starport with hills and a river and crap
        !            55: 0x5c   more landscape poo. starport?
        !            56: 0x5e   6-berth starport with scenery.
        !            57: 0x60   another 6-berth starport + scenery
        !            58: 0x62   2-berth starport (merlin) + big greenhouses and junk
        !            59: 0x64   6-berth starport on a big lump of green. how odd. intro?
        !            60: 0x66   no atmosphere type starport. 2 flashy light towers. dirty industry, etc
        !            61: 0x68   " ". 4 towers.
        !            62: 0x6a   " ". smaller.
        !            63: 0x6c   " ". lots of industry and greenhouses on this one.
        !            64: 0x6e   5 tower thing. industry. not a starport apparently.
        !            65: 0x70   " ". +big fuckoff radar dish
        !            66: 0x72   " ". +greenhouses
        !            67: 0x74   " ". +2 thargoid things.
        !            68: 0x76   Hm. you die. this must be something really big.
        !            69: 0x78   mb-4 mining machine
        !            70: 0x7a   see 0x76
        !            71: 0x7c   an asteroid
        !            72: 0x7e,0x80,0x82,0x84    see 0x76
        !            73: ... do more ...
1.1       root       74: 
                     75: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     76: 
1.1.1.2   root       77: for calling FmtStr:
                     78:        d0 = format type described below
                     79:        d4 = colour
                     80:        d5 = x
                     81:        d6 = y
                     82:        d7 = 0 ??
1.1       root       83: 
                     84: d0:
1.1.1.2   root       85:       < 0x3000  string 'd0' in stringtable L3e878, which contains
                     86:                only "hello there" and "how are you" :-)
1.1       root       87:        0x3015  "%08x" hex (in d3)
                     88:        0x3014  "%08x" hex (in d2)
                     89:        0x3013  "%08x" hex (in d1)
                     90:        0x3012  HH:MM:SS (in d3)
                     91:        0x3011  HH:MM:SS (in d2)
                     92:        0x3010  HH:MM:SS (in d1)
                     93:        0x300f  dd-mon-year (day of year in d3)
                     94:        0x300e  dd-mon-year (in d2)
                     95:        0x300d  dd-mon-year (in d1)
                     96:        0x300c  int32 3 dec places (in d3)
                     97:        0x300b  int32 3 dec places (in d2)
                     98:        0x300a  int32 3 dec places (in d1)
                     99:        0x3009  int32 2 dec places (in d3)
                    100:        0x3008  int32 2 dec places (in d2)
                    101:        0x3007  int32 2 dec places (in d1)
                    102:        0x3006  int32 1 dec place (in d3)
                    103:        0x3005  int32 1 dec place (in d2)
                    104:        0x3004  int32 1 dec place (in d1)
                    105:        0x3003  int32 (in d3)
                    106:        0x3002  int32 (in d2)
                    107:        0x3001  int32 (in d1)
                    108:        0x3000  erm, like, do last thing printed.
1.1.1.2   root      109:        
                    110:        0x4xxx  use string xxx from stringtable A6_game_strings(a6)
                    111:        0x80xx - 0xa2xx
                    112:                use string xxx from stringtable in module given by:
                    113:                12 + a6 + (((d0*2) & 0xffff)>>7)
                    114:                (The module string table is then obtained by jumping
                    115:                to 40(addr), the address calculated above.
                    116:                ( mod0 = 0x80xx, mod1 = 0x82xx, ... )
                    117:        
                    118:                hm. that there copy thingy is 0x98d8
                    119:                
1.1       root      120: 
                    121: SFX indices:
                    122: ~~~~~~~~~~~~~
                    123: 
                    124:        0       ui_beep
                    125:        1       laser0
                    126:        2       laser1
                    127:        3       laser2
                    128:        4       launch_granted
                    129:        5       station_door_open
                    130:        6       explode1
                    131:        7       ??
                    132:        8       explode2
                    133:        9       explode3
                    134:        10      explode4
                    135:        11      explode5
                    136:        12      explode6
                    137:        13      explode7
                    138:        14      explode8
                    139:        15      explode9
                    140:        16      explode10
                    141:        17      laser_burn
                    142:        18      ??
                    143:        19      hyperspace (loop)
                    144:        20      hyperspace_end
                    145:        21      send_message
                    146:        22      fire_missile
                    147:        23      noise (loop)
                    148:        24      ECM
                    149:        25      warning!
                    150:        26      retract wheels (?)
                    151:        27      <silence?>
                    152:        28      select object
                    153:        29      bing
                    154:        30      big bing!
                    155:        31      launch_noise
                    156:        32      dildo
                    157: 
                    158: modfuncs:
                    159: ~~~~~~~~~
                    160: 4(a4) - init
                    161: 20(a4) - every turn in 3d view
1.1.1.2   root      162: 40(a4) - get string-table
                    163: 
                    164: 
                    165: random crap
                    166: ~~~~~~~~~~~~~~~
1.1       root      167: 
1.1.1.2   root      168: the gamedata things the renderer has pointer to in a5:
                    169: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    170: size   offset
                    171: WORD   0               offset added to gamedata pointer before passing to Project3DObj
                    172: WORD   2               offset to another fucking thing in this gamedata obj (L3e14e)
                    173: WORD   4               size of stackframe to allocate in L3e158
                    174: WORD   6               offset to yet another fucking thing in data obj
                    175: WORD   10              some size shift thingy
                    176: WORD   14              some size thingy
                    177: 
                    178: from gamedata + 0(gamedata).w (in a5 at Project3DObj):
                    179: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                    180: size   offset
                    181: WORD   0               (word & 0x1f) * 2 = offset to projection func in L3e10e
                    182:                        Read with (a5)+, Passed to project funcs in d6.w.
                    183: 
                    184: Then different projector functions read their vertex,color,other crap from (a5)+,
                    185: and on return to Project3DObj the next word will be another projection func index.
                    186: Eg: for ProjectQuad_1:
                    187:        Bytes 0,1,2,3 of (a5) are the 4 vertex ids.
                    188:        WORD 4 is colour index of some kind.
                    189: for ProjectTriangle_1:
                    190:        Bytes 0,1,2 are 3 vertex ids.
                    191:        Byte 4 is colour index.
                    192: 
                    193: 
                    194: for shoving objects into the renderer:
                    195: 
                    196: Caller (ejemplo DrawBGStars):
                    197:        # Creates 286 byte stackframe with
                    198:        lea     -286(a7),a7
                    199:        move.l  a7,a6
                    200: 
                    201:        { bg stars
                    202:                20(a6) = 0.l
                    203:                24(a6) = 0.l
                    204:                28(a6) = $200.l
                    205:                90(a6) = $b0.w
                    206:        }
                    207:        { hyperspace cloud (during hyperspace)
                    208:                20(a6) = 0.l
                    209:                24(a6) = 0.l
                    210:                28(a6) = some value (bigger = more distant :)
                    211:                90(a6) = $ba.w
                    212:                116(a6) = 0.w
                    213:                122(a6) = $ffff.w
                    214:        }
                    215:                
                    216:        
                    217:        call Put3DObj:
                    218:                d0 = 90(a6).w
                    219:                a5 = Address of gamedata obj num 'd0.w'.
                    220: 
                    221:                a4 = a6
                    222: 
                    223:                # make 220 byte stackframe
                    224:                link    a6,#-220
                    225: 
1.1.1.3 ! root      226:                # this is the object rotate matrix.
1.1.1.2   root      227:                copy 32 bytes: -36(a6) = 0(a4) [caller stackframe]
                    228: 
                    229:                # so (in viewing coords)
                    230:                -16(a6) = x
                    231:                -12(a6) = y
                    232:                -8(a6) = z
                    233: 
                    234:                # game data shit
                    235:                -208(a6) = WORD 10(a5)
                    236: 
                    237:                -212(a6) = LONG a4 [caller stackframe]
                    238:                -156(a6) = 0.w
                    239:                -192(a6) = 0.w
                    240: 
                    241:                # flags Z if obj is onscreen
                    242:                call 3DObjClipOffscreen
                    243:                if not Z: return
                    244: 
                    245:                -64(a6) = 0.w
1.1.1.3 ! root      246:                * this is an extra color tint value, but is only applied
        !           247:                * if object color (rgb444) bits 4 and 8 are zero.
1.1.1.2   root      248:                -154(a6) = $111.w
                    249:                # lighting vector:
                    250:                copy 3 LONGs: -198(a6) = L60e2    (which is normally 556(a6))
                    251:                copy 4 LONGs: -104(a6) = L60f6    (which is normally 576(a6))
                    252:                
                    253:                call CalcZnLighting
                    254:                        
                    255:                
                    256: 
                    257:        # Destroy stackframe
                    258:        lea     286(a7),a7
1.1.1.3 ! root      259: 
        !           260: 
        !           261: # THIS HERE is a truth table of how object colours are tinted.
        !           262: # obj_col.w is the rgb444 value in the object model, usually in d6
        !           263: * when 3DPrimCullNLight is called
        !           264: * light_col.w is the value returned by 3DPrimCullNLight in (a0)
        !           265: * extra_col is value passed to Put3DObj, in -154(a6).w
        !           266: 
        !           267:                                obj_col bit:    4       8
        !           268: col:
        !           269: light_col + obj_col                            0       0
        !           270: obj_col                                                0       1
        !           271: light_col + obj_col + extra_col                        1       0
        !           272: obj_col + extra_col                            1       1
        !           273:                                                
        !           274: 
1.1.1.2   root      275: call CalcZnLighting:
                    276:        d0-2 = z,y,z
                    277:        d3 = 0
                    278:        d5 = $4000
                    279:        d4 = abs (z)
                    280:        # find a shift value (d3) to keep abs (x,y,z) coords < $4000
                    281:        while (d4 >= $4000) {
                    282:                d3 += 1
                    283:                d4 >>= 1
                    284:        }
                    285:        
                    286:        d4 = abs (x)
                    287:        d4 >>= d3
                    288:        while (d4 >= $4000) {
                    289:                d3 += 1
                    290:                d4 >>= 1
                    291:        }
                    292: 
                    293:        d4 = abs (y)
                    294:        d4 >>= d3
                    295:        while (d4 >= $4000) {
                    296:                d3 += 1
                    297:                d4 >>= 1
                    298:        }
                    299: 
                    300:        # all LONG
                    301:        x >>= d3
                    302:        y >>= d3
                    303:        z >>= d3
                    304: 
                    305:        # save shift val
                    306:        -44(a6) = WORD d3
                    307:        d3 += 7
                    308:        d4 -= WORD -208(a6)
                    309: 
                    310:        if (d3 < 0) {
                    311:                d3 = abs (d3)
                    312:                -44(a6) += WORD d3
                    313:                WORD x >>= d3
                    314:                WORD y >>= d3
                    315:                WORD z >>= d3
                    316:        }
                    317:        x = -x
                    318:        y = -y
                    319:        z = -z
                    320: 
                    321:        # WORD 3x3 matrix M[9] at -36(a6)
                    322:        x1 = HIGH WORD 2*(x*M[0] + y*M[1] + z*M[2])
                    323:        y1 = HIGH WORD 2*(x*M[3] + y*M[4] + z*M[5])
                    324:        z1 = HIGH WORD 2*(x*M[6] + y*M[7] + z*M[8])
                    325:        -50(a6) = WORD x1,y1,z1
                    326: 
                    327:        # Lighting vector
                    328:        x,y,z = -198(a6)
                    329:        x2 = HIGH WORD 2*(x*M[0] + y*M[1] + z*M[2])
                    330:        y2 = HIGH WORD 2*(x*M[3] + y*M[4] + z*M[5])
                    331:        z2 = HIGH WORD 2*(x*M[6] + y*M[7] + z*M[8])
                    332:        -42(a6) = WORD x2,y2,z2
                    333:        return
                    334:        
                    335: 
                    336: # flags Z if obj is onscreen
                    337: call 3DObjClipOffscreen:
                    338:        # a5 still game data shit
                    339:        x,y,z = viewing coords
                    340:        d3 = LONG (WORD 14(a5) << WORD -208(a6))
                    341:        z += d3
                    342:        # object behind viewer
                    343:        if z < 0: return
                    344:        x = abs x
                    345:        y = abs y
                    346:        x -= d3
                    347:        if x >= 0 goto l3966e
                    348:        x = 0
                    349:        l3966e:
                    350:        if x > z: return
                    351:        y -= d3
                    352:        if y >= 0: goto l39678
                    353:        y = 0
                    354:        l39678:
                    355:        y *= 2
                    356:        if y > z: return
                    357:        x = 0
                    358:        return
                    359:                
                    360: L3e14e:
                    361:        -216(a6) = LONG (gamedata + 2(gamedata).w)
                    362:        #alloc stackframe: 
                    363:        a7 -= WORD 4(gamedata)
                    364:        a4 = a7
                    365:        # and then some more
                    366:        a7 -= WORD 8(gamedata)
                    367:        a7 -= $c0
                    368:        # save gamedata obj pointer
                    369:        -4(a6) = LONG a5
                    370:        -220(a6) = LONG gamedata + 6(gamedata).w
                    371:        
                    372:        # -208(a6) is 10(a5)
                    373:        d4 = WORD -208(a6)
                    374:        d4 -= WORD 8
                    375:        # that shift val
                    376:        d4 -= -44(a6)
                    377:        
                    378:        if (d4 > 0) {
                    379:                shift each value in vector3 -50(a6) >> d4.
                    380:        }
                    381:        # we are the only caller of this func
                    382:        call L39690:
                    383:                # a4 is the stackframe allocated previously
                    384:                # a4 has 4(gamedata).w bytes below it and
                    385:                # 8(gamedata).w + $c0 bytes above.
                    386:                a0 = a4 + 18
                    387:                -160(a0) = 0.w
                    388:                -128(a0) = 0.w
                    389:                -96(a0) = 0.w
                    390:                -64(a0) = 0.w
                    391:                -32(a0) = 0.w
                    392:                # and then it is wiped according to the length in d0,
                    393:                # every 32 fuckheads
                    394:                return
                    395:        # also only caller of this one
                    396:        call L3a00c:
                    397:                a0 = 4(a7)
                    398:                d1 = 8(gamedata).w   # which is frame size above a4...
                    399:                # wtf is -98(a6)...
                    400:                (a0)+ = LONG -98(a6)
                    401:                d1 >>= 1
                    402:                d1 -= 3
                    403:                if (d1 < 0) return
                    404:                do {
                    405:                        (a0)+ = #$8080.w
                    406:                } while (--d1 != -1)
                    407:                return
                    408:        # OK. so this a4 stackframe now looks like:
                    409:        # from 4(a7) to -160(a4) (len 8(gamedata).w) filled with $8080
                    410:        # -160(a4) to (4(gamedata).w + a4), every 32-bytes = 0.w
                    411:        #
                    412:        # The bit below a4 with 32-byte chunks is for storing model vertices
                    413:        # transformed to viewing coords. It goes like this:
                    414:        # WORD*2        0       projected 2D x,y coords
                    415:        # LONG*3        4       20 + viewing transform
                    416:        # WORD          18      zero if this vertex has not been setup yet
                    417:        # LONG*3        20      model coords transformed by model rotation
                    418:        #
                    419:        -152(a6) = $2.b
                    420:        a5 += WORD 0(a5)
                    421:        
                    422:        # phew..
                    423:        call Project3DObj....
                    424:        
                    425:        lea     -224(a6),a7
                    426:        return
                    427: 
                    428: 3DPrimCullNLight:
                    429:        ARG d0 = WORD (BYTE color id thingy)*2
                    430:        a1 = LONG -220(a6) # gamedata + 6(gamedata).w
                    431:        
                    432:        bclr    #1,d0
                    433:        if (bit 1 was set) {
                    434:                # XXX finish...
                    435:        }
                    436:        d1,d3 = WORD -4(a1,d0.w)
                    437:        d0 = d1
                    438:        d1 <<= 8
                    439:        d2 = d3
                    440:        d2 &= 0xff00
                    441:        d3 <<= 8
                    442:        d0 >>= 7
                    443:        d0 &= 0xfffe
                    444: 
                    445: For ProjectCoords:
                    446:        Input:
                    447:                model coords    3xl     20(a0)
                    448:                world coords    3xl     -16(a6)
                    449:        Output:
                    450:                model+world     3xl     4(a0)
1.1.1.3 ! root      451:                z-component ^^  l       12(a0)
1.1.1.2   root      452:                2d projection   2xw     0(a0)
1.1       root      453: 
1.1.1.3 ! root      454: Draw3DView:
        !           455:        pos = primitives_base
        !           456: 
        !           457:        for (;;) {
        !           458:                FUCK:
        !           459:                push pos;
        !           460:                
        !           461:                if (pos[8].l) {
        !           462:                        pos = pos[8].l
        !           463:                        continue;
        !           464:                }
        !           465:                break;
        !           466:        }
        !           467: 
        !           468:        call L386ce + pos[12].w
        !           469: 
        !           470:        for (;;) {
        !           471:                pop pos
        !           472:                
        !           473:                if (pos[4].l) {
        !           474:                        pos = pos[4].l
        !           475:                        goto FUCK
        !           476:                }
        !           477:                peek pos
        !           478: 
        !           479:                call L386ce + pos[12].w
        !           480:        }
        !           481: 
        !           482: ###################
        !           483: 2d primitive numbers:
        !           484: 
        !           485: 0x5a - bezier section of complex polygon
        !           486: 
        !           487: ProjectPlanet:
        !           488: ~~~~~~~~~~~~~~
        !           489: 
        !           490: Allocates 214 bytes on stack in a3.
        !           491: 
        !           492: 32(a3).w = (d6 {as passed to function} >> 4) & 0xfffe 
        !           493: 194(a3).l = a5 {as passed} + 4
        !           494: # planet feature detail
        !           495: 172(a3).w = 16 + optdetail2
        !           496: # load some crap into a0:
        !           497: lea 0(a4,d0.w),a0 where d0 = (a5)+ byte extended to word << 5
        !           498: 120(a3).w*3 = x,y,z of planet (fucked around with in some way. these notes are crap)
        !           499: 36(a3) = 8 words containing some unknown shit.
        !           500: 56(a3) = 2 words of shite
        !           501: 80(a3) = 4 longs of shite
        !           502: 60(a3) = 2 words of shite
        !           503: 206(a3).w = $10
        !           504: 96(a3).w = $5
        !           505: 48(a3) = 2 words
        !           506: 64(a3) = 2 words
        !           507: 52(a3) = 2 words
        !           508: 76(a3) = 2 words
        !           509: 
        !           510: # the ship object that is read (a5)
        !           511: (d6.w >> 4) & 0xfffe -> 32(a3)
        !           512: (a5)+.l
        !           513: (a5)+.w * 4
        !           514: (a5)+.w
        !           515: lea 56(a5),a5
        !           516: (a5)+.w * 4
        !           517: 
        !           518: if (a5)+.w == 0: goto poop1
        !           519: 
        !           520: poop2: oh fuck this is horrible
        !           521: 
        !           522: poop1:
        !           523: 
        !           524: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.