1: / bj -- black jack
   2: 
   3: .globl _signal
   4:         mov     $prtot, -(sp)
   5:         mov     $2,-(sp)
   6:         jsr     pc,_signal
   7:         cmp     (sp)+,(sp)+
   8:         jsr     r5,mesg; <Black Jack\n\0>; .even
   9:         mov     sp,gsp
  10:         clr     r0
  11: 1:
  12:         movb    r0,deck(r0)
  13:         inc     r0
  14:         cmp     r0,$52.
  15:         blo     1b
  16: 
  17: game:
  18:         mov     gsp,sp
  19:         jsr     r5,mesg; <new game\n\0>; .even
  20:         clr     dbjf
  21:         add     taction,action
  22:         clr     taction
  23:         jsr     pc,shuffle
  24:         jsr     r5,quest5
  25:         mov     total,stotal
  26:         jsr     pc,card
  27:         mov     cval,upval
  28:         mov     aceflg,upace
  29:         jsr     pc,peek
  30:         mov     r0,dhole
  31:         mov     cval,r0
  32:         add     upval,r0
  33:         cmp     r0,$21.
  34:         bne     1f
  35:         inc     dbjf
  36: 1:
  37:         jsr     r5,mesg; < up\n\0>; .even
  38:         jsr     pc,card
  39:         mov     cval,ival
  40:         mov     aceflg,iace
  41:         mov     $'+,r0
  42:         jsr     pc,putc
  43:         mov     $-1,-(sp)
  44:         mov     $-1,-(sp) / safety
  45:         clr     dflag
  46:         br      1f
  47: 
  48: doubl:
  49:         cmp     dflag,$1
  50:         beq     2f
  51:         jmp     dmove
  52: 2:
  53:         inc     dflag
  54: 1:
  55:         mov     ival,value
  56:         mov     iace,naces
  57:         mov     $1,fcard
  58:         mov     bet,-(sp)
  59: 
  60: hit:
  61:         jsr     pc,card
  62:         jsr     pc,nline
  63:         jsr     pc,nline
  64:         add     cval,value
  65:         add     aceflg,naces
  66:         dec     fcard
  67:         bge     2f
  68:         jmp     1f
  69: 2:
  70:         add     bet,taction
  71:         tst     dflag
  72:         bne     2f
  73:         tst     upace
  74:         beq     2f
  75:         jsr     r5,mesg; <Insurance? \0>; .even
  76:         jsr     r5,quest1
  77:                 br 2f
  78:         mov     bet,r0
  79:         add     r0,total
  80:         asr     r0
  81:         add     r0,taction
  82:         tst     dbjf
  83:         bne     2f
  84:         sub     r0,total
  85:         asl     r0
  86:         sub     r0,total
  87: 2:
  88:         tst     dflag
  89:         beq     2f
  90:         cmp     ival,$11.
  91:         beq     3f
  92: 2:
  93:         cmp     value,$21.
  94:         bne     2f
  95:         tst     dflag
  96:         bne     2f
  97:         jsr     r5,mesg; <You have black jack!\n\0>; .even
  98:         tst     (sp)+
  99:         tst     dbjf
 100:         bne     doubl
 101:         mov     bet,r0
 102:         add     r0,total
 103:         asr     r0
 104:         add     r0,total
 105:         br      doubl
 106: 2:
 107:         tst     dbjf
 108:         bne     3f
 109:         cmp     cval,ival
 110:         bne     2f
 111:         tst     dflag
 112:         bne     2f
 113:         jsr     r5,mesg; <Split pair? \0>; .even
 114:         jsr     r5,quest2
 115:                 br 2f
 116:         inc     dflag
 117:         tst     (sp)+
 118:         br      1b
 119: 2:
 120:         cmp     value,$10.
 121:         blo     1f
 122:         cmp     value,$11.
 123:         bhi     1f
 124:         jsr     r5,mesg; <Double down? \0>; .even
 125:         jsr     r5,quest3
 126:                 br 1f
 127:         add     (sp),(sp) / double bet
 128:         add     bet,taction
 129:         jsr     pc,card
 130:         jsr     pc,nline
 131:         add     cval,value
 132: 3:
 133:         cmp     value,$21.
 134:         blos    stick
 135:         sub     $10.,value
 136:         br      stick
 137: 1:
 138:         cmp     value,$21.
 139:         blos    1f
 140:         dec     naces
 141:         bge     2f
 142:         jsr     r5,mesg; <You bust\n\0>
 143:         sub     (sp)+,total
 144:         jmp     doubl
 145: 2:
 146:         sub     $10.,value
 147:         br      1b
 148: 1:
 149:         jsr     r5,mesg; <Hit? \0>; .even
 150:         jsr     r5,quest4
 151:                 br stick
 152:         jmp     hit
 153: 
 154: stick:
 155:         tst     dbjf
 156:         bne     1f
 157:         jsr     r5,mesg; <You have \0>; .even
 158:         mov     value,r0
 159:         jsr     pc,decml
 160:         jsr     pc,nline
 161: 1:
 162:         mov     value,-(sp)
 163:         jmp     doubl
 164: 
 165: dmove:
 166:         tst     (sp)
 167:         blt     addin
 168:         jsr     r5,mesg; <Dealer has \0>; .even
 169:         mov     dhole,peekf
 170: 
 171: dhit:
 172:         jsr     pc,card
 173:         add     cval,upval
 174:         add     aceflg,upace
 175:         tst     dbjf
 176:         beq     1f
 177:         jsr     r5,mesg; < = blackjack\n\0>; .even
 178:         mov     $22.,upval
 179:         br      addin
 180: 1:
 181:         cmp     upval,$21.
 182:         blos    1f
 183:         dec     upace
 184:         bge     2f
 185:         jsr     r5,mesg; < = bust\n\0>; .even
 186:         clr     upval
 187:         br      addin
 188: 2:
 189:         sub     $10.,upval
 190:         br      1b
 191: 1:
 192:         cmp     upval,$17.
 193:         bhis    1f
 194:         mov     $'+,r0
 195:         jsr     pc,putc
 196:         br      dhit
 197: 1:
 198:         jsr     r5,mesg;< = >; .even
 199:         mov     upval,r0
 200:         jsr     pc,decml
 201:         jsr     pc,nline
 202: 
 203: addin:
 204:         mov     (sp)+,r0
 205:         blt     2f
 206:         cmp     upval,r0
 207:         bne     1f
 208:         tst     (sp)+
 209:         br      addin
 210: 1:
 211:         blt     1f
 212:         sub     (sp)+,total
 213:         br      addin
 214: 1:
 215:         add     (sp)+,total
 216:         br      addin
 217: 2:
 218:         mov     total,r0
 219:         sub     stotal,r0
 220:         jsr     pc,dollars
 221:         jmp     game
 222: 
 223: shuffle:
 224:         cmp     mod,$15.
 225:         bhis    1f
 226:         jsr     r5,mesg; <Shuffle\n\0>; .even
 227:         jsr     pc,pract
 228:         mov     $52.,mod
 229:         mov     $16.,tens
 230:         mov     $36.,others
 231: 1:
 232:         rts     pc
 233: 
 234: card:
 235:         jsr     pc,peek
 236:         mov     cden,r0
 237:         jsr     pc,putc
 238:         mov     csuit,r0
 239:         jsr     pc,putc
 240:         cmp     cval,$10.
 241:         beq     1f
 242:         dec     others
 243:         rts     pc
 244: 1:
 245:         dec     tens
 246:         rts     pc
 247: 
 248: peek:
 249:         mov     peekf,-(sp)
 250:         bne     1f
 251:         cmp     mod,$1
 252:         bgt     2f
 253:         jsr     pc,shuffle
 254: 2:
 255:         jsr     r5,rand; mod: 0
 256:         dec     mod
 257:         movb    deck(r0),(sp)
 258:         mov     mod,r1
 259:         movb    deck(r1),deck(r0)
 260:         movb    (sp),deck(r1)
 261:         inc     (sp)
 262: 1:
 263:         clr     peekf
 264:         mov     (sp),r1
 265:         dec     r1
 266:         clr     r0
 267:         div     $4.,r0
 268:         movb    denom(r0),cden
 269:         movb    suit(r1),csuit
 270:         clr     aceflg
 271:         tst     r0
 272:         bne     1f
 273:         inc     aceflg
 274:         mov     $11.,r0
 275:         br      2f
 276: 1:
 277:         inc     r0
 278:         cmp     r0,$10.
 279:         blos    2f
 280:         mov     $10.,r0
 281: 2:
 282:         mov     r0,cval
 283:         mov     (sp)+,r0
 284:         rts     pc
 285: 
 286: prtot:
 287:         jsr     pc,nline
 288:         jsr     pc,pract
 289:         jmp     done
 290: 
 291: pract:
 292:         tst     action
 293:         beq     1f
 294:         jsr     r5,mesg; <Action $\0>; .even
 295:         mov     action,r0
 296:         jsr     pc,decml
 297:         mov     total,r0
 298:         jsr     pc,dollars
 299: 1:
 300:         rts     pc
 301: 
 302: dollars:
 303:         mov     r0,-(sp)
 304:         blt     1f
 305:         bne     2f
 306:         jsr     r5,mesg; <\nYou break even\0>; .even
 307:         tst     (sp)+
 308:         br      3f
 309: 2:
 310:         jsr     r5,mesg; <\nYou win $\0>; .even
 311:         br      2f
 312: 1:
 313:         jsr     r5,mesg; <\nYou lose $\0>; .even
 314:         neg     (sp)
 315: 2:
 316:         mov     (sp)+,r0
 317:         jsr     pc,decml
 318: 3:
 319:         jsr     pc,nline
 320:         rts     pc
 321: 
 322: denom:  <A23456789TJQK>
 323: suit:   <HSDC>
 324: deck:   .=.+52.
 325:         .even
 326: 
 327: cval:   .=.+2
 328: aceflg: .=.+2
 329: cden:   .=.+2
 330: csuit:  .=.+2
 331: peekf:  .=.+2
 332: dhole:  .=.+2
 333: dbjf:   .=.+2
 334: upval:  .=.+2
 335: upace:  .=.+2
 336: value:  .=.+2
 337: taction:        .=.+2
 338: action: .=.+2
 339: naces:  .=.+2
 340: ival:   .=.+2
 341: iace:   .=.+2
 342: gsp:    .=.+2
 343: dflag:  .=.+2
 344: fcard:  .=.+2
 345: stotal: .=.+2
 346: total:  .=.+2

Defined functions

aceflg defined in line 328; used 6 times
action defined in line 338; used 3 times
addin defined in line 203; used 6 times
card defined in line 234; used 5 times
cden defined in line 329; used 2 times
csuit defined in line 330; used 2 times
cval defined in line 327; used 9 times
dbjf defined in line 333; used 7 times
deck defined in line 324; used 5 times
denom defined in line 322; used 1 times
dflag defined in line 343; used 8 times
dhit defined in line 171; used 1 times
dhole defined in line 332; used 2 times
dmove defined in line 165; used 1 times
  • in line 51
dollars defined in line 302; used 2 times
doubl defined in line 48; used 4 times
fcard defined in line 344; used 2 times
game defined in line 17; used 1 times
gsp defined in line 342; used 2 times
  • in line 9, 18
hit defined in line 60; used 1 times
iace defined in line 341; used 2 times
ival defined in line 340; used 4 times
mod defined in line 255; used 5 times
naces defined in line 339; used 3 times
peek defined in line 248; used 2 times
peekf defined in line 331; used 3 times
pract defined in line 291; used 2 times
prtot defined in line 286; used 1 times
  • in line 4
shuffle defined in line 223; used 2 times
stick defined in line 154; used 3 times
stotal defined in line 345; used 2 times
suit defined in line 323; used 1 times
taction defined in line 337; used 5 times
total defined in line 346; used 11 times
upace defined in line 335; used 4 times
upval defined in line 334; used 10 times
value defined in line 336; used 12 times
Last modified: 1987-08-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2802
Valid CSS Valid XHTML 1.0 Strict