1; SCCS Id: @(#)dispmap.s 3.2 94/04/19 2;Copyright (c) Andrew Church, Olney, Maryland, 1994. 3;NetHack may be freely redistributed. See license for details. 4 5;Display the game map (using tiles). 6; 7;Call from C: display_map(struct Window *win) 8;where win is the window to draw the map in. 9; 10;At the moment, this routine is limited to tile display sizes of 8, 16, 11;24, 32, and 48 pixels square (determined by mxsize/mysize). 12; 13;This code depends on structs amiv_glyph_node and PDAT. If either of 14;these are changed, the corresponding offsets below will also need to be 15;changed. 16 17;struct BitMap 18bm_BytesPerRow equ 0 19bm_Rows equ 2 20bm_Flags equ 4 21bm_Depth equ 5 22bm_Planes equ 8 23bm_sizeof equ 40 24 25;struct Window (incomplete) 26wd_LeftEdge equ 4 27wd_TopEdge equ 6 28wd_RPort equ 50 29wd_BorderLeft equ 54 30wd_BorderTop equ 55 31 32;struct RastPort (incomplete) 33rp_BitMap equ 4 34 35;struct amiv_glyph_node 36gn_odstx equ 0 37gn_odsty equ 2 38gn_srcx equ 4 39gn_srcy equ 6 40gn_dstx equ 8 41gn_dsty equ 10 42gn_bitmap equ 12 43gn_sizeof equ 16 44 45;struct PDAT 46pdat_nplanes equ 0 47pdat_pbytes equ 4 48pdat_across equ 8 49pdat_down equ 12 50pdat_npics equ 16 51pdat_xsize equ 20 52pdat_ysize equ 24 53pdat_sizeof equ 28 54 55 section text,code 56 57 xdef _display_map 58 xdef loop ;for debugging 59 xdef put8 ; | 60 xdef put16 ; | 61 xdef put24 ; | 62 xdef put32 ; | 63 xdef put48 ; V 64 xref _glyph_node_index 65 xref _amiv_g_nodes 66 xref _pictdata 67 xref _mxsize 68 xref _mysize 69 xref _clipping 70 xref _clipx 71 xref _clipy 72 xref _clipxmax 73 xref _clipymax 74 xref _amii_extraplanes 75 xref _reclip 76 77;display_map(struct Window *vw) 78; 79;Register usage: 80; D0 - temp 81; D1 - temp 82; D2 - glyph_node loop counter 83; D3 - temp 84; D4 - Number of planes to use 85; D5 - index (bytes) into tile bitmap 86; D6 - temp 87; D7 - temp 88; A0 - tile bitmap 89; A1 - overview window bitmap 90; A2 - amiv_g_nodes[] 91; A3 - tile display routine (depends on requested tile size) 92; A4 - data base (from main program) 93; A5 - source bitplane \ used by 94; A6 - dest bitplane / putNN 95; 96;Passed to putNN on stack: 97; [ 0(a7) - return address ] 98; 4(a7) - BytesPerRow of tile bitmap 99; 6(a7) - BytesPerRow of overview bitmap 100; 8(a7) - Bitmap offset to beginning of top row of window 101; 12(a7) - X coordinate of left edge of window 102 103_display_map: 104 cmp.l #2,_reclip 105 bne dispmap 106 rts 107dispmap move.l 4(a7),a1 108 movem.l d2-d7/a2-a3/a5-a6,-(a7) 109 move.l a1,a6 110 move.l wd_RPort(a6),a1 111 move.l rp_BitMap(a1),a1 112 move.w bm_BytesPerRow(a1),d0 113 pea bm_Planes(a1) 114 lea _pictdata,a0 115 move.l pdat_nplanes(a0),d4 116 add.l _amii_extraplanes,d4 117 move.w d4,-(a7) 118 move.w wd_TopEdge(a6),d1 119 mulu d0,d1 120 move.w wd_LeftEdge(a6),-(a7) 121 move.l d1,-(a7) 122 move.w d0,-(a7) 123 subq.l #2,a7 124 lea _amiv_g_nodes,a2 125 move.l _mxsize,d5 126 move.w _glyph_node_index,d2 127 subq.w #1,d2 128 cmp.w #8,d5 129 beq set8 130 cmp.w #16,d5 131 beq set16 132 cmp.w #24,d5 133 beq set24 134 cmp.w #32,d5 135 beq set32 136 lea put48(pc),a3 137 bra loop 138set8 lea put8(pc),a3 139 bra loop 140set16 lea put16(pc),a3 141 bra loop 142set24 lea put24(pc),a3 143 bra loop 144set32 lea put32(pc),a3 145loop move.l gn_bitmap(a2),a0 146 tst.l _clipping 147 beq noclip 148 moveq #0,d0 149 move.w gn_odstx(a2),d0 150 cmp.l _clipx,d0 151 blt endlp 152 cmp.l _clipxmax,d0 153 bge endlp 154 move.w gn_odsty(a2),d0 155 cmp.l _clipy,d0 156 blt endlp 157 cmp.l _clipymax,d0 158 bge endlp 159noclip moveq #0,d5 160 move.w gn_srcx(a2),d5 161 lsr.w #3,d5 162 move.w gn_srcy(a2),d0 163 move.w bm_BytesPerRow(a0),d7 164 mulu d7,d0 165 add.l d0,d5 166 lea bm_Planes(a0),a0 167 move.w d7,(a7) 168 move.w 10(a7),d4 169 move.l 12(a7),a1 170 jsr (a3) 171endlp lea gn_sizeof(a2),a2 172 dbf d2,loop 173 lea 16(a7),a7 174 movem.l (a7)+,d2-d7/a2-a3/a5-a6 175 rts 176 177 178put8: 179 subq.w #1,d4 180 move.w 4(a7),d7 181 add.w d7,d7 182 moveq #0,d3 183 move.w gn_dstx(a2),d3 184 add.w 12(a7),d3 185 lsr.w #3,d3 186 move.w gn_dsty(a2),d0 187 mulu 6(a7),d0 188 add.l d0,d3 189 add.l 8(a7),d3 190p8Plp moveq #7,d6 191 move.l (a0)+,a5 192 add.l d5,a5 193 move.l (a1)+,a6 194 add.l d3,a6 195p8Ylp move.w (a5),d0 ;No loops here - they'd slow this down 196 lsl.w #1,d0 197 roxl.b #1,d1 198 lsl.w #2,d0 199 roxl.b #1,d1 200 lsl.w #2,d0 201 roxl.b #1,d1 202 lsl.w #2,d0 203 roxl.b #1,d1 204 lsl.w #2,d0 205 roxl.b #1,d1 206 lsl.w #2,d0 207 roxl.b #1,d1 208 lsl.w #2,d0 209 roxl.b #1,d1 210 lsl.w #2,d0 211 roxl.b #1,d1 212 move.b d1,(a6) 213 add.w d7,a5 214 add.w 6(a7),a6 215 dbf d6,p8Ylp 216 dbf d4,p8Plp 217 rts 218 219put16: 220 subq.w #1,d4 221 move.w 6(a7),d7 222 moveq #0,d3 223 move.w gn_dstx(a2),d3 224 add.w 12(a7),d3 225 lsr.w #3,d3 226 move.w gn_dsty(a2),d0 227 mulu d7,d0 228 add.l d0,d3 229 add.l 8(a7),d3 230p16Plp moveq #15,d6 231 move.l (a0)+,a5 232 add.l d5,a5 233 move.l (a1)+,a6 234 add.l d3,a6 235p16Ylp move.w (a5),d0 236 move.b d0,1(a6) 237 lsr.w #8,d0 238 move.b d0,(a6) 239 add.w 4(a7),a5 240 add.w d7,a6 241 dbf d6,p16Ylp 242 dbf d4,p16Plp 243 rts 244 245put24: 246 move.w d2,-(a7) 247 subq.w #1,d4 248 move.w 8(a7),d7 249 moveq #0,d3 250 move.w gn_dstx(a2),d3 251 add.w 14(a7),d3 252 lsr.w #3,d3 253 move.w gn_dsty(a2),d0 254 mulu d7,d0 255 add.l d0,d3 256 add.l 10(a7),d3 257p24Plp moveq #7,d6 258 move.l (a0)+,a5 259 add.l d5,a5 260 move.l (a1)+,a6 261 add.l d3,a6 262p24Ylp move.w (a5),d0 263 moveq #0,d1 264 add.w d0,d0 265 scs d2 266 and.b #3,d2 267 or.b d2,d1 268 add.w d0,d0 269 roxl.l #1,d1 270 add.w d0,d0 271 scs d2 272 and.b #3,d2 273 lsl.l #2,d1 274 or.b d2,d1 275 add.w d0,d0 276 roxl.l #1,d1 277 add.w d0,d0 278 scs d2 279 and.b #3,d2 280 lsl.l #2,d1 281 or.b d2,d1 282 add.w d0,d0 283 roxl.l #1,d1 284 add.w d0,d0 285 scs d2 286 and.b #3,d2 287 lsl.l #2,d1 288 or.b d2,d1 289 add.w d0,d0 290 roxl.l #1,d1 291 add.w d0,d0 292 scs d2 293 and.b #3,d2 294 lsl.l #2,d1 295 or.b d2,d1 296 add.w d0,d0 297 roxl.l #1,d1 298 add.w d0,d0 299 scs d2 300 and.b #3,d2 301 lsl.l #2,d1 302 or.b d2,d1 303 add.w d0,d0 304 roxl.l #1,d1 305 add.w d0,d0 306 scs d2 307 and.b #3,d2 308 lsl.l #2,d1 309 or.b d2,d1 310 add.w d0,d0 311 roxl.l #1,d1 312 add.w d0,d0 313 scs d2 314 and.b #3,d2 315 lsl.l #2,d1 316 or.b d2,d1 317 add.w d0,d0 318 roxl.l #1,d1 319 swap d1 320 move.b d1,(a6) 321 swap d1 322 move.b d1,2(a6) 323 lsr.w #8,d1 324 move.b d1,1(a6) 325 add.w 6(a7),a5 326 add.w d7,a6 327 move.w (a5),d0 328 moveq #0,d1 329 add.w d0,d0 330 scs d2 331 and.b #3,d2 332 or.b d2,d1 333 add.w d0,d0 334 roxl.l #1,d1 335 add.w d0,d0 336 scs d2 337 and.b #3,d2 338 lsl.l #2,d1 339 or.b d2,d1 340 add.w d0,d0 341 roxl.l #1,d1 342 add.w d0,d0 343 scs d2 344 and.b #3,d2 345 lsl.l #2,d1 346 or.b d2,d1 347 add.w d0,d0 348 roxl.l #1,d1 349 add.w d0,d0 350 scs d2 351 and.b #3,d2 352 lsl.l #2,d1 353 or.b d2,d1 354 add.w d0,d0 355 roxl.l #1,d1 356 add.w d0,d0 357 scs d2 358 and.b #3,d2 359 lsl.l #2,d1 360 or.b d2,d1 361 add.w d0,d0 362 roxl.l #1,d1 363 add.w d0,d0 364 scs d2 365 and.b #3,d2 366 lsl.l #2,d1 367 or.b d2,d1 368 add.w d0,d0 369 roxl.l #1,d1 370 add.w d0,d0 371 scs d2 372 and.b #3,d2 373 lsl.l #2,d1 374 or.b d2,d1 375 add.w d0,d0 376 roxl.l #1,d1 377 add.w d0,d0 378 scs d2 379 and.b #3,d2 380 lsl.l #2,d1 381 or.b d2,d1 382 add.w d0,d0 383 roxl.l #1,d1 384 swap d1 385 move.b d1,0(a6,d7.w) 386 move.b d1,(a6) 387 swap d1 388 move.b d1,2(a6,d7.w) 389 move.b d1,2(a6) 390 lsr.w #8,d1 391 move.b d1,1(a6,d7.w) 392 move.b d1,1(a6) 393 add.w 6(a7),a5 394 add.w d7,a6 395 add.w d7,a6 396 dbf d6,p24Ylp 397 dbf d4,p24Plp 398 move.w (a7)+,d2 399 rts 400 401put32: 402 move.w d2,-(a7) 403 subq.w #1,d4 404 move.w 8(a7),d7 405 moveq #0,d3 406 move.w gn_dstx(a2),d3 407 add.w 14(a7),d3 408 lsr.w #3,d3 409 move.w gn_dsty(a2),d0 410 mulu d7,d0 411 add.l d0,d3 412 add.l 10(a7),d3 413p32Plp moveq #15,d6 414 move.l (a0)+,a5 415 add.l d5,a5 416 move.l (a1)+,a6 417 add.l d3,a6 418p32Ylp move.w (a5),d0 419 moveq #0,d1 420 add.w d0,d0 421 scs d2 422 and.b #$C0,d2 423 or.b d2,d1 424 add.w d0,d0 425 scs d2 426 and.b #$30,d2 427 or.b d2,d1 428 add.w d0,d0 429 scs d2 430 and.b #$0C,d2 431 or.b d2,d1 432 add.w d0,d0 433 scs d2 434 and.b #$03,d2 435 or.b d2,d1 436 move.b d1,0(a6,d7.w) 437 move.b d1,(a6)+ 438 moveq #0,d1 439 add.w d0,d0 440 scs d2 441 and.b #$C0,d2 442 or.b d2,d1 443 add.w d0,d0 444 scs d2 445 and.b #$30,d2 446 or.b d2,d1 447 add.w d0,d0 448 scs d2 449 and.b #$0C,d2 450 or.b d2,d1 451 add.w d0,d0 452 scs d2 453 and.b #$03,d2 454 or.b d2,d1 455 move.b d1,0(a6,d7.w) 456 move.b d1,(a6)+ 457 moveq #0,d1 458 add.w d0,d0 459 scs d2 460 and.b #$C0,d2 461 or.b d2,d1 462 add.w d0,d0 463 scs d2 464 and.b #$30,d2 465 or.b d2,d1 466 add.w d0,d0 467 scs d2 468 and.b #$0C,d2 469 or.b d2,d1 470 add.w d0,d0 471 scs d2 472 and.b #$03,d2 473 or.b d2,d1 474 move.b d1,0(a6,d7.w) 475 move.b d1,(a6)+ 476 moveq #0,d1 477 add.w d0,d0 478 scs d2 479 and.b #$C0,d2 480 or.b d2,d1 481 add.w d0,d0 482 scs d2 483 and.b #$30,d2 484 or.b d2,d1 485 add.w d0,d0 486 scs d2 487 and.b #$0C,d2 488 or.b d2,d1 489 add.w d0,d0 490 scs d2 491 and.b #$03,d2 492 or.b d2,d1 493 move.b d1,0(a6,d7.w) 494 move.b d1,(a6) 495 add.w 6(a7),a5 496 add.w d7,a6 497 lea -3(a6,d7.w),a6 498 dbf d6,p32Ylp 499 dbf d4,p32Plp 500 move.w (a7)+,d2 501 rts 502 503put48: 504 move.w d2,-(a7) 505 subq.w #1,d4 506 move.w d4,-(a7) 507 move.l d5,-(a7) 508 move.w 14(a7),d7 509 moveq #0,d3 510 move.w gn_dstx(a2),d3 511 add.w 20(a7),d3 512 lsr.w #3,d3 513 move.w gn_dsty(a2),d0 514 add.l 16(a7),d3 515 mulu d7,d0 516 add.l d0,d3 517 move.w d7,d5 518 add.w d5,d5 519p48Plp moveq #15,d6 520 move.l (a0)+,a5 521 add.l (a7),a5 522 move.l (a1)+,a6 523 add.l d3,a6 524p48Ylp move.w (a5),d0 525 moveq #0,d1 526 moveq #21,d4 527 moveq #0,d2 528 add.w d0,d0 529 scs d2 530 and.b #7,d2 531 lsl.l d4,d2 532 or.l d2,d1 533 subq.w #3,d4 534 moveq #0,d2 535 add.w d0,d0 536 scs d2 537 and.b #7,d2 538 lsl.l d4,d2 539 or.l d2,d1 540 subq.w #3,d4 541 moveq #0,d2 542 add.w d0,d0 543 scs d2 544 and.b #7,d2 545 lsl.l d4,d2 546 or.l d2,d1 547 add.w d0,d0 548 scs d2 549 ext.w d2 550 and.w #$7000,d2 551 or.w d2,d1 552 add.w d0,d0 553 scs d2 554 ext.w d2 555 and.w #$E00,d2 556 or.w d2,d1 557 add.w d0,d0 558 scs d2 559 ext.w d2 560 and.w #$1C0,d2 561 or.w d2,d1 562 add.w d0,d0 563 scs d2 564 and.b #$38,d2 565 or.b d2,d1 566 add.w d0,d0 567 scs d2 568 ext.w d2 569 and.b #7,d2 570 or.b d2,d1 571 swap d1 572 move.b d1,0(a6,d7.w) 573 move.b d1,0(a6,d5.w) 574 move.b d1,(a6)+ 575 rol.l #8,d1 576 move.b d1,0(a6,d7.w) 577 move.b d1,0(a6,d5.w) 578 move.b d1,(a6)+ 579 rol.l #8,d1 580 move.b d1,0(a6,d7.w) 581 move.b d1,0(a6,d5.w) 582 move.b d1,(a6)+ 583 moveq #0,d1 584 moveq #21,d4 585 moveq #0,d2 586 add.w d0,d0 587 scs d2 588 and.b #7,d2 589 lsl.l d4,d2 590 or.l d2,d1 591 subq.w #3,d4 592 moveq #0,d2 593 add.w d0,d0 594 scs d2 595 and.b #7,d2 596 lsl.l d4,d2 597 or.l d2,d1 598 subq.w #3,d4 599 moveq #0,d2 600 add.w d0,d0 601 scs d2 602 and.b #7,d2 603 lsl.l d4,d2 604 or.l d2,d1 605 add.w d0,d0 606 scs d2 607 ext.w d2 608 and.w #$7000,d2 609 or.w d2,d1 610 add.w d0,d0 611 scs d2 612 ext.w d2 613 and.w #$E00,d2 614 or.w d2,d1 615 add.w d0,d0 616 scs d2 617 ext.w d2 618 and.w #$1C0,d2 619 or.w d2,d1 620 add.w d0,d0 621 scs d2 622 and.b #$38,d2 623 or.b d2,d1 624 add.w d0,d0 625 scs d2 626 ext.w d2 627 and.b #7,d2 628 or.b d2,d1 629 swap d1 630 move.b d1,0(a6,d7.w) 631 move.b d1,0(a6,d5.w) 632 move.b d1,(a6)+ 633 rol.l #8,d1 634 move.b d1,0(a6,d7.w) 635 move.b d1,0(a6,d5.w) 636 move.b d1,(a6)+ 637 rol.l #8,d1 638 move.b d1,0(a6,d7.w) 639 move.b d1,0(a6,d5.w) 640 move.b d1,(a6) 641 add.w 12(a7),a5 642 add.w d7,a6 643 lea -5(a6,d5.w),a6 644 dbf d6,p48Ylp 645 subq.w #1,4(a7) 646 bpl p48Plp 647 move.l (a7)+,d5 648 addq.l #2,a7 649 move.w (a7)+,d2 650 rts 651 652 end 653